水晶报表CrystalReport2008使用JDBC连接Oracle数据库-详细步骤
连接的数据库可以改成MySQL,详细的在连接数据库的时候说明.
一: 前期准备工作
l Crystal Report 2008
l JDBC 相关jar包 --- ojdbc5.jar(Oracle) 或 mysql-connector-java-5.1.7.jar(MySQL)
Jar包下载:
ojdbc5.jar http://www.oracle.com/technetwork/cn/articles/oem/jdbc-112010-094555-zhs.html
mysql-connector-java-5.1.7.jar http://www.mysql.com/downloads/connector/j/
JAR包添加:
1. 把JAR包放在水晶报表CrystalReport的目录下面
C:\Program Files\Business Objects\Common\4\java\lib\external
2. 然后找到 JAR包的配置文件CRConfig.xml
C:\Program Files\Business Objects\Common\4\java\CRConfig.xml
3. 打开CRConfig.xml 在<Classpath>添加
<Classpath>C:\Program Files\Business Objects\Common\4.0\java/lib/external/ojdbc5.jar;
C:\Program Files\Business Objects\Common\4.0\java/lib/crlovmanifest.jar;
C:\Program Files\Business Objects\Common\4.0\java/lib/CRLOVExternal.jar;
C:\Program Files\Business Objects\Common\4.0\java/lib/CRDBJDBCServer.jar;
C:\Program Files\Business Objects\Common\4.0\java/lib/CRDBXMLServer.jar;
C:\Program Files\Business Objects\Common\4.0\java/lib/CRDBJavaBeansServer.jar;
C:\Program Files\Business Objects\Common\4.0\java/lib/external/CRDBXMLExternal.jar;
C:\Program Files\Business Objects\Common\4.0\java/lib/external/log4j.jar;
C:\Program Files\Business Objects\Common\4.0\java/lib/CRDBSForceServer.jar;
C:\Program Files\Business Objects\Common\4.0\java/lib/external/CRDBSForceExternal.jar;${CLASSPATH}</Classpath>
MySQL 则添加mysql-connector-java-5.1.7.jar
JAR包添加完毕!
准备工作完成!
三: 打开Crystal Report 2008
打开file> new> stander report
Connection URL : jdbc:oracle:thin:@name:port:sid
例如: --- ( jdbc:oracle:thin:@localhost:1521:dev)
Database ClassName: oracle.jdbc.driver.OracleDriver
至此成功连接数据库.
END
2012-10-16