I am not able to find the WebLogic CLASSPATH variable in either of these two files - commEnv.sh and commEnv.cmd. I do not understand where to add sqljdbc42 nor how to connect to an Azure SQL Server Database (is that even possible)?
I downloaded sqljdbc42.jar from MSDN and added it to my $DOMAIN/lib but where is the CLASSPATH; I do not see one to modify. As I understand, I need to add the path to the JAR.
C:\Oracle\Middleware\Oracle_Home\wlserver\common\bin
commEnv.cmd - no classpath:
IF NOT DEFINED MW_HOME (
IF NOT DEFINED WL_HOME (
echo MW_HOME or WL_HOME is not set
IF DEFINED USE_CMD_EXIT (
EXIT 1
) ELSE (
EXIT /B 1
)
)
)
IF NOT DEFINED MW_HOME set MW_HOME=%WL_HOME%\..
FOR %%i IN ("%MW_HOME%") DO SET MW_HOME=%%~fsi
CALL "%MW_HOME%\oracle_common\common\bin\commEnv.cmd"
commEnv.sh - no classpath:
if [ -z "${MW_HOME}" -a -z "${WL_HOME}" ]; then
echo "MW_HOME or WL_HOME is not set."
exit 1
fi
if [ -z "${MW_HOME}" ]; then
MW_HOME="${WL_HOME}/.."
fi
. "${MW_HOME}/oracle_common/common/bin/commEnv.sh"
Major and minor versions have to be supported and synchronized. That is to say, you must use sqljdbc4.jar in your project class path and place a copy of that jar in $DOMAIN/lib for Oracle WebLogic, where $DOMAIN for me was C:\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain\lib
. There were no other files in this directory, but if you read the readme.txt it will tell you that you do not need to modify the classpath. For me, looking into commEnv.cmd or other such files, there was no classpath at all. The specific error I received was:
java.lang.UnsupportedClassVersionError:
com/microsoft/sqlserver/jdbc/SQLServerDriver : Unsupported major.minor version 52.0
I used the link below to help me install sqljdbc in Maven, so I can add the needed dependency in my POM file: http://techmajik.com/2014/04/24/how-to-setup-maven-dependency-for-microsoft-sql-server/
Optionally, I added the below piece of code to invoke the driver. Many answers here recommended it and even pointed to scenarios where creating a connection will not work without it.
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
I was on an Azure SQL Database. This is important as there is an additional step - firewall settings must be properly configured from the Azure dashboard. I used the below MSDN guide to help me perform these steps: http://blogs.msdn.com/b/azuresqldbsupport/archive/2015/04/29/configuring-the-firewall-for-client-access.aspx