Am trying to connect MS SQL server through java web applications.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
connection= DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=XXX;integratedSecurity=true");
I have copied "sqljdbc_auth.dll" to $Tomcat_home/bin and copied jar into $Tomcat_home/lib folder.
I Have multiple web apps in same tomcat instance.
The first webApp loads and successfully establishes the connection with MS SQL.
But the remaining apps fail to connect to MS SQL prompting:
com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:41d72756-1383-427e-8c4f-c3075ae1559a
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2400)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<init>(AuthenticationJNI.java:68)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3132)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43)
Note: Tomcat runs as windows service. And MSSQL is configured to windows authentication.
edit:
I understand that the native library (DLL) can only be loaded into the JVM once, hence the error, but I after looking around the net I still have no solution.
sqljdbc_auth.dll is need to use windows authentication or Kerberos authentication.
Get the dll from Microsoft and install it either by:
drop on application library folder
drop on the java bin folder.
Not recommended if you want to package the applications with all the
dependencies. Also, it requires to find what java version is being
used and from what path.
drop the library on some folder and then add the path in the command line:
java -Djava.library.path=<library path>...
The mssql-jdbc driver and the sqljdbc_auth.dll should be:
on the same folder
both from the same version
for the same architecture (x86/x64) JVM is running.
Check also the jdbc comparability matrix with java versions.
The JDBC driver supports the use of Type 2 integrated authentication on Windows operating systems through the integratedSecurity connection string property. To use integrated authentication, copy the sqljdbc_auth.dll file to a directory on the Windows system path on the computer where the JDBC driver is installed.
Alternatively you can set the java.libary.path system property to specify the directory of the sqljdbc_auth.dll. For example, if the JDBC driver is installed in the default directory, you can specify the location of the DLL by using the following virtual machine (VM) argument when the Java application is started:
-Djava.library.path=c:/sqljdbc_<version>/enu/auth/x86
or
-Djava.library.path=c:/sqljdbc_<version>/enu/auth/x64
Please read more about in the original documentation:
https://learn.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-2017
In order to be able to connect with the JDBC, you need to define the connection as follows:
"jdbc:sqlserver://*******
;authenticationScheme=NTLM;integratedSecurity=true;domain=******
****;databasename=**********;encrypt =
true;trustServerCertificate=true;user=*******;password=*******;"
Use the following dependency:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>10.2.0.jre8</version>
</dependency>
I am trying to configure activiti to communicate ms-sql 2014 with windows authentication instead of with username/password in connection url.
What i have done ?
downloaded JDBC Driver, put sqljdbc4-3-0.jar in JAVA_HOME and in the web-info\lib
put sqljdbc_auth.dll (64bit) in C:\Windows\System32
set integrated security in db.properties as following:
db.properties (C:\Workflow\apache-tomcat-7.0.62\webapps\activiti-explorer\WEB-INF\classes):
db=mssql
jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://127.0.0.1:1433;databaseName=activiti;integratedSecurity=true;
When using regular authentication (I remove the integratedSecurity=true and add user=XXX and password=XXX it works!)
When I open log the last line is:
DEBUG org.springframework.jdbc.datasource.SimpleDriverDataSource: Creating new JDBC Driver Connection to [jdbc:sqlserver://localhost;databaseName=activiti;integratedSecurity=true;]
Then the java application shutsdown and i see hs_err_pid4232.log as attached with exception:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000061a3cf13, pid=4232, tid=8080
What can cause this not to work ?
I want thinking maybe it did not load the DLL/JARS it should be in order to use JDBC driver ? the sql server config looks like this:
The log of process crush is at: http://pastebin.com/xpW5yvEP
This error screams "trouble with the authentication dll". Try these steps:
Download latest sqljdbc, unzip it locally from here: https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774
put the .jar in your classpath and the .dll in your library path. Try using a "real" path by adding -Djava.library.path=PATH/TO/DLL into your startup.
run java -fullversion to make sure you have the right .dll (32 bit vs 64 bit) installed there.
run program again.
I can't get the connection to work for Oracle WebLogic 12c using SQL Developer. Here is the error that I get when I click connect:
An error was encountered performing the requested operation:
/usr/lib/java/libocijdbc11.dylib: dlopen(/usr/lib/java/libocijdbc11.dylib, 1): Library not loaded: /ade/b/2475221476/oracle/rdbms/lib/libclntsh.dylib.11.1
Referenced from: /usr/lib/java/libocijdbc11.dylib
Reason: image not found
Vendor code 0
When I click Test in the Settings of SQL Developer I get the following log:
Testing the Instant Client located at /usr/lib/java
Testing client directory ... OK
Testing loading Oracle JDBC driver ... OK
Testing checking Oracle JDBC driver version ... OK
Driver version: 11.2.0.3.0
Testing testing native OCI library load ... Failed:
Error loading the native OCI library
The native OCI driver could not be loaded. The system propertyjava.library.path
contains the entries from the environment variable DYLD_LIBRARY_PATH.
Check it to verify that the expected native library
directory /usr/lib/java is present and precedes any other client installations.
java.library.path = /Users/gasim/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Here is an outline of my setup:
Operating system: OSX Mavericks (10.9.4 to be specific)
The Java SE Runtime version: "1.8.0" (build "1.8.0_11-b12")
Oracle Instant is located under /usr/lib/java. The directory is set in the SQL Developer (through Database > Advanced)
The Oracle server is up and running with default parameters (localhost:7001) and I can access the web admin console.
Oracle Instant Client version: 11.2.0.4.0
java.library.path = /Users/gasim/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
The directory listing of /usr/lib/java:
BASIC_README
adrci
genezi
libclntsh.dylib.11.1
libnnz11.dylib
libocci.dylib.11.1
libociei.dylib
libocijdbc11.dylib
ojdbc5.jar
ojdbc6.jar
uidrvci
xstreams.jar
The thing is, libocijdbc11.dylib does exist in /usr/lib/java and that directory is in the library path of java. I just don't get it. Am I missing something here? What else can I try for solving this problem or at least debugging deeper?
I'll tell you how I solved, finally...
I'm running OSX 10.9.4, with jboss 7.1.1.Final installed through brew, and an env variable JBOSS_HOME=/usr/local/opt/jboss-as/libexec.
I already had an ojdbc.jar in $JBOSS_HOME/modules/com/oracle/main, version 11.2.0.3, so I downloaded Instant Client version 11.2.0.3.
I commented any JAVA_OPTS that was populating java.library.path with instantclient libraries, like this:
#JAVA_OPTS="$JAVA_OPTS -Djava.library.path=$JBOSS_HOME/instantclient_11_2"
I copied, for being comfortable, instantclient_11_2 inside $JBOSS_HOME.
It's just a matter of doing:
export DYLD_LIBRARY_PATH=$JBOSS_HOME/instantclient_11_2
$JBOSS_HOME/bin/standalone.sh
It now works. Now I have another problem to solve:
Native Library /usr/local/Cellar/jboss-as/7.1.1.Final/libexec/instantclient_11_2/libocijdbc11.dylib already loaded in another classloader
When I connect the database with JDBC i get this:
[StatAggResultCollector] Test Started, host: *local*
[StatAggResultCollector] Test Ended, host: *local*
in response message I get:
java.sql.SQLException: No suitable driver found for jdbc:oracle:..
Any solution?
Is this from jdbc driver or from configuration?
Looks like JMeter cannot find the Oracle driver.
Have you put the ojdbc14.jar or classes12.zip (which contains Oracle drivers) file in the JMETER/lib directory
For Oracle database 9 and 10 use ojdbc14.jar for Oracle database 11 use ojdbc5.jar if you use java 1.5 or ojdbc6.jar if you use java 1.6. Check java version in jmeter.bat file.
I've got a problem with JDBC.
I'have the following code:
//blargeparam is a blob column.
PreparedStatement pst =connection.prepareStatement("update gcp_processparams_log set blargeparam= ? where idprocessparamslog=1");
pst.setBinaryStream(1,inputStream);
I get the following error:
Exception in thread "main" java.lang.AbstractMethodError:
oracle.jdbc.driver.T2CPreparedStatement.setBinaryStream(ILjava/io/InputStream;)V
My connection string is jdbc:oracle:oci:#.....
The Oracle version is 11g.
From the error message it seems that something is missing but:
when I read from the same blob column
(with blob.getBytes) everything
works.
The DLL's of the instant client are
(correctly) in the library path.
This is the manifest of the Oracle
JDBC JAR in my class path:
Manifest-Version: 1.0
Specification-Title: Oracle JDBC driver classes for use with JDK14
Sealed: true
Created-By: 1.4.2_14 (Sun Microsystems Inc.)
Implementation-Title: ojdbc14.jar
Specification-Vendor: Oracle Corporation
Specification-Version: Oracle JDBC Driver version - "10.2.0.4.0"
Implementation-Version: Oracle JDBC Driver version - "10.2.0.4.0"
Implementation-Vendor: Oracle Corporation
Implementation-Time: Sat Feb 2 11:40:29 2008
With JDBC, that error usually occurs because your JDBC driver implements an older version of the JDBC API than the one included in your JRE. These older versions are fine so long as you don't try and use a method that appeared in the newer API.
I'm not sure what version of JDBC setBinaryStream appeared in. It's been around for a while, I think.
Regardless, your JDBC driver version (10.2.0.4.0) is quite old, I recommend upgrading it to the version that was released with 11g (download here), and try again.
It looks that even if the driver 10.2 is compatible with the JDBC3 it may not work with JRE6
as I've found here:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#02_03
Which JDBC drivers support which versions of Javasoft's JDK?
pre-8i OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
8.1.5 OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
8.1.6SDK THIN Driver - JDK 1.1.x and JDK 1.2.x (aka Java2)
8.1.6SDK OCI Driver - Only JDK 1.1.x
8.1.6 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
8.1.7 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
9.0.1 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x and JDK 1.3.x
9.2.0 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
10.1.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
10.2.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, JDK 1.4.x, and JDK 5.0.x
11.1.0 OCI and THIN Driver - JDK 1.5.x and JDK 1.6.x
Oracle 10.2.0 supports:
Full support for JDBC 3.0
Note that there is no real change in the support for the following in the database. Allthat has changed is that some methods that previously threw SQLException now do something more reasonable instead.
result-set holdability
returning multiple result-sets.
Here's what the JDK API says about AbstractMethodError:
Thrown when an application tries to
call an abstract method. Normally,
this error is caught by the compiler;
this error can only occur at run time
if the definition of some class has
incompatibly changed since the
currently executing method was last
compiled.
Bug in the oracle driver, maybe?
Just put ojdbc6.jar in class path, so that we can fix CallbaleStatement exception:
oracle.jdbc.driver.T4CPreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V)
in Oracle.
As described in the API of java.sql.PreparedStatement.setBinaryStream() it is available since 1.6 so it is a JDBC 4.0 API! You use a JDBC 3 Driver so this method is not available!
Just use ojdb6.jar and will fix all such issues.
For maven based applications:
Download and copy ojdbc6.jar to a directory in your local machine
From the location where you have copied your jar install the ojdbc6.jar in your local .M2 Repo by issuing below command
C:\SRK\Softwares\Libraries>mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3
-Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true
Add the below in your project pom.xml as ojdbc6.jar dependency
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
PS: The issue might be due to uses of #Lob annotation in JPA for storing large objects specifically in oracle db columns. Upgrading to 11.2.0.3 (ojdbc6.jar) can resolve the issue.
In my case this was the error.
Exception in thread "main" java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z
at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.isValid(DelegatingConnection.java:917)
at org.apache.tomcat.dbcp.dbcp2.PoolableConnection.validate(PoolableConnection.java:282)
at org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:356)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2306)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2289)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2038)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1532)
at beans.Test.main(Test.java:24)
Solution: I just change ojdbc14.jar to ojdbc6.jar
I would suggest investigating your classpath very carefully. You might have two different versions of a jar file where one invokes methods in the other and the other method is abstract.
In my case problem was at context.xml file of my project.
The following from context.xml causes the java.lang.AbstractMethodError, since we didn't show the datasource factory.
<Resource name="jdbc/myoracle"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#(DESCRIPTION = ... "
username="****" password="****" maxActive="10" maxIdle="1"
maxWait="-1" removeAbandoned="true"/>
Simpy adding factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" solved the issue:
<Resource name="jdbc/myoracle"
auth="Container"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#(DESCRIPTION = ... "
username="****" password="****" maxActive="10" maxIdle="1"
maxWait="-1" removeAbandoned="true"/>
To make sure I reproduced the issue several times by removing factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" from Resource
I do meet this problem.
use ojdbc14.jar and jdk 1.6
InputStream in = new FileInputStream(file);
cstmt.setBinaryStream(1, in,file.length()); // got AbstractMethodError
InputStream in = new FileInputStream(file);
cstmt.setBinaryStream(1, in,(int)file.length()); // no problem.
InputStream in = new FileInputStream(file);
cstmt.setBinaryStream(1, in,file.length());
instead of this u need to use
InputStream in = new FileInputStream(file);
cstmt.setBinaryStream(1, in,(int)file.length());
The problem is due to older version of ojdbc - ojdbc14.
Place the latest version of ojdbc jar file in your application or shared library.
(Only one version should be there and it should be the latest one)
As of today - ojdbc6.jar
Check the application libraries and shared libraries on server.
I think, the reason of the error from JDBC driver, you should get suitable JDBC driver for your Oracle db. You can get it from
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
I got the same problem and resolved it.
To resolve this problem, you should upgrade commons-dbcp library to latest version (1.4). It will work with latest JDBC drivers.