加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

jasperserver4.0.1设置数据源

发布时间:2020-12-13 17:52:18 所属栏目:百科 来源:网络整理
导读:JasperReports Server can connect to just about any data source. JasperReports Server comes standard with connection wizards for JDBC,JNDI,and Bean (Java bean) data sources. Jaspersoft also offers an extensible environment for including cus

JasperReports Server can connect to just about any data source. JasperReports Server comes standard with connection wizards for JDBC,JNDI,and Bean (Java bean) data sources. Jaspersoft also offers an extensible environment for including custom data sources in screens etc. Check the JasperServer Users Guide for details.

Contents

[hide ]
  • 1 Acquire the Database Driver Package
  • 2 Copy the Driver to the Classpath
  • 3 Optional JNDI Configuration
  • 4 Restart JasperReports Server
  • 5 Define the Data Source in JasperReports Server
    • 5.1 jTDS (for Microsoft SQL Server)
    • 5.2 Microsoft SQL Server
    • 5.3 Oracle (thin driver)
    • 5.4 PostgreSQL
  • 6 Troubleshooting

Acquire the Database Driver Package

JasperReports Server redistributes a MySQL database driver. If you need to connect to another database,you will need to acquire the appropriate driver and add it the application server's classpath.

Here are some links that may assist. Check with your DBA to ensure you are using the correct driver.

  • jTDS driver for SQL Server and Sybase: http://jtds.sourceforge.net/
  • Microsoft SQL Server: http://msdn.microsoft.com/en-us/data/aa937724.aspx
  • Oracle: http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
  • PostgreSQL: http://jdbc.postgresql.org/

Extract the downloaded files to an easily accessed location. For example,c:/jdbc/ or /usr/share. Locate the actual driver name. You will copy it to the classpath in the next step.

Sample driver names include:

  • jTDS: jtds-1.2.2.jar
  • Microsoft SQL Server: sqljdbc4.jar (for JDK 1.6/6.0),sqljdbc.jar (JDK 1.5/5.0)
  • Oracle: ojdbc14.jar
  • PostgreSQL: postgresql-8.1-407.jdbc3.jar

Copy the Driver to the Classpath

You need to copy the driver (the .jar file) to the classpath.

In general it's best to copy the driver to the application server's shared library location. Refer to your application server documentation for exact locations. Sample locations include:

  • Tomcat5: <Catalina_home>/common/lib
  • Tomcat6: <Catalina_home>/lib
  • JBoss5: <jboss_home>/server/all/lib

Optional JNDI Configuration

You can define a JNDI connection in your application server. The database drivers must be in the application server's shared library classpath (see the previous section ).

The technique you use to define the JNDI connection will vary by application server. For Tomcat,you can define the JNDI connection within JasperReports Server by editing <tomcat_home>/webapps/jasperserver-pro/META-INF/context.xml. Use the sample configurations as a guide.

Restart JasperReports Server

Restart the application server. If you installed JasperReports Server using the Windows installer,there is a shortcut in the start menu to restart it.

Define the Data Source in JasperReports Server

1. Log into JasperServer's web site. http://localhost:8080/jasperserver-pro

2. Go to View | Repository.

3. Click the second icon called Add Resource and select Data Source.

4. Choose a data source type and click next.

5. Provide any Name,Label,and Description.

6. If you selected the JDBC connection type,you will typically enter values such as these samples:

jTDS (for Microsoft SQL Server)

  • driver: net.sourceforge.jtds.jdbc.Driver
  • url: jdbc:jtds:sqlserver://host:1433/yourDatabase

Microsoft SQL Server

  • driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
  • url: jdbc:sqlserver://host:1433;databaseName=yourDatabase

Oracle (thin driver)

  • driver: oracle.jdbc.OracleDriver
  • url: jdbc:oracle:thin:@host:1521:your_db_instance_name
  • example url: jdbc:oracle:thin:@remotehost:1521:orcl
  • example url: jdbc:oracle:thin:@localhost:1521:xe

PostgreSQL

  • driver: org.postgresql.Driver
  • url: jdbc:postgresql://host:5432/yourDatabase

7. Click Test and it should succeed.

Troubleshooting

If it doesn't succeed,save anyway and restart the JasperReports Server and watch for any exceptions.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读