cancel
Showing results for 
Search instead for 
Did you mean: 

Error loading JDBC driver

Former Member
0 Kudos

Hi,

I have an rpt file developed in crystal report 2008. it connects to SQL Server using ODBC(RDO) connection. I have a jsp file that needs to change the datasource to use JDBC (JNDI). The scriptlet for changing datasource is given below. I have my sqljdbc.jar in the web-inf\lib folder of my application as well as in \server\{server_name}\lib folder. when I try to run the jsp it gives me error as follows :

ERROR [com.businessobjects.reports.sdk.JRCCommunicationAdapter] detected an exception: Error loading JDBC driver. The class 'com.microsoft.jdbc.sqlserver.SQLServerDriver' could not be found.

at com.crystaldecisions.reports.queryengine.Connection.t1(Unknown Source)

at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.a(Unknown Source)

at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.for(Unknown Source)

at com.crystaldecisions.reports.reportdefinition.ReportHelper.a(Unknown Source)

at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.long(Unknown Source)

at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.a(Unknown Source)

at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.byte(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.do(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.a(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.call(Unknown Source)

at com.crystaldecisions.reports.common.ThreadGuard.syncExecute(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.for(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.int(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)

at com.businessobjects.sdk.erom.jrc.a.a(Unknown Source)

at com.businessobjects.sdk.erom.jrc.a.execute(Unknown Source)

at com.crystaldecisions.proxy.remoteagent.RemoteAgent$a.execute(Unknown Source)

at com.crystaldecisions.proxy.remoteagent.CommunicationChannel.a(Unknown Source)

at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.ds.a(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)

at ....

<br>

<br>

Scriptlet :

<%

//Report can be opened from the relative location specified in the CRConfig.xml, or the report location

//tag can be removed to open the reports as Java resources or using an absolute path (absolute path not recommended

//for Web applications).

final String DBUSERNAME = "sa";

final String DBPASSWORD = "password";

final String CONNECTION_STRING = "!com.microsoft.jdbc.sqlserver.SQLServerDriver!jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=;user=;password="; final String TRUSTEDCON = "false"; final String PREQESERVERNAME = "jdbc:microsoft:sqlserver://localhost:1433"; final String SERVERTYPE = "JDBC (JNDI)"; final String DATABASE_DLL = "crdb_jdbc.dll"; final String DATABASE = "bssc"; final String DBCLASSNAME = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; final String USEJDBC = "true"; final String DATABASE_NAME = "bssc"; final String SERVERNAME = "jdbc:microsoft:sqlserver://localhost:1433"; final String CONNECTIONURL = "jdbc:microsoft:sqlserver://localhost:1433"; final String SERVER = "localhost"; %> <% final Logger logger = Logger.getLogger(ReportAction.class.getName()); final String REPORT_NAME = "../reports/Krt.rpt"; try { ReportClientDocument oReportClientDocument = new ReportClientDocument(); oReportClientDocument.open(REPORT_NAME, 0); // Create the two connectioninfo objects to use IConnectionInfo oldConnectionInfo = new ConnectionInfo(); IConnectionInfo newConnectionInfo = new ConnectionInfo(); // Assign the old Connection info to the reports current info DatabaseController dbController = oReportClientDocument.getDatabaseController(); oldConnectionInfo = dbController.getConnectionInfos(null).getConnectionInfo(0); // If this connection needed parameters, we would use this field. Fields pFields = null; // Create a new propertybag for the new location PropertyBag boPropertyBag1 = new PropertyBag(); // Set new table logon properties boPropertyBag1.put("JDBC Connection String", CONNECTION_STRING); boPropertyBag1.put("Trusted_Connection", TRUSTEDCON); boPropertyBag1.put("PreQEServerName", PREQESERVERNAME); boPropertyBag1.put("Server Type", SERVERTYPE); boPropertyBag1.put("Database DLL", DATABASE_DLL); boPropertyBag1.put("Database", DATABASE); boPropertyBag1.put("Database Class Name", DBCLASSNAME); boPropertyBag1.put("Use JDBC", USEJDBC); boPropertyBag1.put("Database Name", DATABASE_NAME); boPropertyBag1.put("Server Name", SERVERNAME); boPropertyBag1.put("Connection URL", CONNECTIONURL); boPropertyBag1.put("Server", SERVER); // Assign the properties to the connection info newConnectionInfo.setAttributes(boPropertyBag1); // Set the DB Username and Pwd newConnectionInfo.setUserName(DBUSERNAME); newConnectionInfo.setPassword(DBPASSWORD); // The Kind of connectionInfos is SQL newConnectionInfo.setKind(ConnectionInfoKind.SQL); // set the parameters to replace. // The 4 options are: // _doNotVerifyDB // _ignoreCurrentTableQualifiers // _mapFieldByRowsetPosition // _useDefault int replaceParams = DBOptions._ignoreCurrentTableQualifiers + DBOptions._doNotVerifyDB; // Now replace the connections dbController.replaceConnection(oldConnectionInfo, newConnectionInfo, pFields, replaceParams); %> <% //Report can be opened from the relative location specified in the CRConfig.xml, or the report location //tag can be removed to open the reports as Java resources or using an absolute path (absolute path not recommended //for Web applications). final String DBUSERNAME = "sa"; final String DBPASSWORD = "password"; final String CONNECTION_STRING = "!com.microsoft.jdbc.sqlserver.SQLServerDriver!jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=;user=;password=";

final String TRUSTEDCON = "false";

final String PREQESERVERNAME = "jdbc:microsoft:sqlserver://localhost:1433";

final String SERVERTYPE = "JDBC (JNDI)";

final String DATABASE_DLL = "crdb_jdbc.dll";

final String DATABASE = "bssc";

final String DBCLASSNAME = "com.microsoft.jdbc.sqlserver.SQLServerDriver";

final String USEJDBC = "true";

final String DATABASE_NAME = "bssc";

final String SERVERNAME = "jdbc:microsoft:sqlserver://localhost:1433";

final String CONNECTIONURL = "jdbc:microsoft:sqlserver://localhost:1433";

final String SERVER = "localhost";

%>

<%

final Logger logger = Logger.getLogger(ReportAction.class.getName());

final String REPORT_NAME = "../reports/Krt.rpt";

try {

ReportClientDocument oReportClientDocument = new ReportClientDocument();

oReportClientDocument.open(REPORT_NAME, 0);

// Create the two connectioninfo objects to use

IConnectionInfo oldConnectionInfo = new ConnectionInfo();

IConnectionInfo newConnectionInfo = new ConnectionInfo();

// Assign the old Connection info to the reports current info

DatabaseController dbController = oReportClientDocument.getDatabaseController();

oldConnectionInfo = dbController.getConnectionInfos(null).getConnectionInfo(0);

// If this connection needed parameters, we would use this field.

Fields pFields = null;

// Create a new propertybag for the new location

PropertyBag boPropertyBag1 = new PropertyBag();

// Set new table logon properties

boPropertyBag1.put("JDBC Connection String", CONNECTION_STRING);

boPropertyBag1.put("Trusted_Connection", TRUSTEDCON);

boPropertyBag1.put("PreQEServerName", PREQESERVERNAME);

boPropertyBag1.put("Server Type", SERVERTYPE);

boPropertyBag1.put("Database DLL", DATABASE_DLL);

boPropertyBag1.put("Database", DATABASE);

boPropertyBag1.put("Database Class Name", DBCLASSNAME);

boPropertyBag1.put("Use JDBC", USEJDBC);

boPropertyBag1.put("Database Name", DATABASE_NAME);

boPropertyBag1.put("Server Name", SERVERNAME);

boPropertyBag1.put("Connection URL", CONNECTIONURL);

boPropertyBag1.put("Server", SERVER);

// Assign the properties to the connection info

newConnectionInfo.setAttributes(boPropertyBag1);

// Set the DB Username and Pwd

newConnectionInfo.setUserName(DBUSERNAME);

newConnectionInfo.setPassword(DBPASSWORD);

// The Kind of connectionInfos is SQL

newConnectionInfo.setKind(ConnectionInfoKind.SQL);

// set the parameters to replace.

// The 4 options are:

// _doNotVerifyDB

// _ignoreCurrentTableQualifiers

// _mapFieldByRowsetPosition

// _useDefault

int replaceParams = DBOptions._ignoreCurrentTableQualifiers + DBOptions._doNotVerifyDB;

// Now replace the connections

dbController.replaceConnection(oldConnectionInfo, newConnectionInfo, pFields, replaceParams);

%>

I am not sure why it is not able to get the Driver since the required jar is there in lib folder? Am I missing something ?

Edited by: sb-onward on Jul 30, 2009 6:01 PM

Accepted Solutions (1)

Accepted Solutions (1)

ted_ueda
Employee
Employee
0 Kudos

The ClassName you have for the driver is incorrect.

Also - web apps don't require the jar files to be placed in CRConfig.xml - that's only used in the Designer.

Sincerely,

Ted Ueda

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks Ted, you are a star

Former Member
0 Kudos

Hi,

Make sure you have set the Classpath in CRConfig.xml for the jdbc jar.

Place the CrConfig.xml in the classes directory of your application.

Please let me know the results.

Regards,

Neeraj

Former Member
0 Kudos

In one of the post I saw that CRConfig.xml is not required for a web application since the a web server takes care of loading the jar file. Are you sure we need to make the jar file entries in this file ?