I'm trying to create a datasource from weblogic 10.3 to sqlserverexpress 2008 r2, but when I test the connection, the following message appears :
Cannot load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
What should I do?
If you have problems connecting to SQL Server using the JDBC driver, see Troubleshooting Connectivity for suggestions on how to correct it. The simplest approach to creating a connection to a SQL Server database is to load the JDBC driver and call the getConnection method of the DriverManager class, as in the following:
You can get the JAR file from msdn.microsoft.com/en-us/sqlserver/aa937724 To use third-party JDBC drivers that are not installed with WebLogic Server, you can add them to the DOMAIN_HOME/lib directory, where DOMAIN_HOME represents the directory in which the WebLogic Server domain is configured.
This release of Microsoft JDBC Driver for SQL Server is available in the following languages: Microsoft JDBC Driver 9.4.1 for SQL Server (zip): Chinese (Simplified) | Chinese (Traditional) | English (United States) | French | German | Italian | Japanese | Korean | Portuguese (Brazil) | Russian | Spanish
Opening a ticket with Oracle, the recommendation was to use a different driver for the data server, com.microsoft.sqlserver.jdbc.SQLServerDriver. That worked.
You need to add the sqlserver JDBC driver jar file to the weblogic classpath.
From weblogic 1221 documentation here :
To use third-party JDBC drivers that are not installed with WebLogic Server, you can add them to the DOMAIN_HOME/lib directory, where DOMAIN_HOME represents the directory in which the WebLogic Server domain is configured. The default path is ORACLE_HOME/user_projects/domains. For more information, see "Adding JARs to the Domain /lib Directory" in Developing Applications for Oracle WebLogic Server.
This solution seems better than updating the weblogic class path, as it will impact the other domains. For example say two domains want to use different versions of the jdbc driver. In this case updating the class path through commEnv.cmd might case issues. Of course the flip side would be that you have to place/link the driver jars in both the domian's lib directory.
I add sqljdbc4.jar to %WLHome%/Server/Lib and i add the following line to the weblogic_classpath in %WLHome%\common\bin\commEnv.cmd: ";%WL_HOME%\server\lib\sqljdbc4.jar"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With