JDBC with MSSQL on tomcat7 catalina - java

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.

Related

SQLException: this driver is not configured for integrated authentication tomcat

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>

How to access *.mv.db file of H2 database?

I have created database with my own program and it appeared as mydatabase.mv.db file.
But when I tried to access the same database with DbVisualizer, with apparently same parameters, it created two files mydatabase.lock.db and celebrity.h2.db and didn't see tables, created in the program.
What was the incompatibility?
UPDATE
both setups are follows:
In H2 version 1.3.x, the database file <databaseName>.h2.db is the default. (The storage engine "PageStore" is used).
In H2 version 1.4.x, the database file <databaseName>.mv.dbis the default. (The storage engine "MVStore" is used). The MVStore is still beta right now (November 2014). But you can disable the MVStore by appending ;mv_store=false to the database URL.
The accepted answer is now several years old and since others may be looking for a more "current" solution...
To get it to work just update the H2 JDBC driver that DBVizualizer uses. Basically download the "Platform-Independent Zip" from http://www.h2database.com/html/download.html and copy the h2/bin/h2-X.X.X.jar file to ~/.dbvis/jdbc/ and then restart DBVizualizer so it can pick up the updated driver.
Also, make sure you remove .mv.db from the file name when setting the Database file name in DBVizualizer.
For Windows Users:
The excellent way to read a *.db.mv file would be locally installing the h2 database and then running that database locally with the java command.
Then your path to the file will definitely show the data from your table until and unless any errors occur.
You can download the h2 database form:
http://www.h2database.com/html/download-archive.html
Note: choose the database version for H2 which supports your file.
You can install the H2 database by installing the downloaded .exe file would be around 7 MB.
then in the bin directory of H2 open a command prompt and run the command
java -jar in my case it is
command: java -jar h2-1.4.200.jar
It will show the console of the H2 database on the browser
Provide the database details:
Driver Class: org.h2.Driver JDBC
URL: jdbc:h2:~/h2 "file path"
User Name: "blank by default"
Password: "blank by default"
Refer SS below
enter image description here

oracle sql developer connection error

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

How to add mysql connector to Sqoop 1.99.3

I have installed Hadoop & connected with Hadoop locally successful. I can connect the Sqoop via REST api and via cli interface.
But once I want to start creating a job for important data from MySQL. It shows
Connection configuration Warning message: Can't connect to the
database with given credentials: No suitable driver found for
jdbc:mysql://127.0.0.1:3306/for
Error message: Can't load specified driver
after google its solution, I has already
put the mysql-connector.jar to sqoop web lib folder
create a lib folder under the sqoop folder and put the mysql-connector.jar in it
I also have restarted or even reboot my VM. It still says cannot load specified driver.
Is there any config files I have missed to set? Thank you!
My ENV:
VirtualBox + Vagrant + Ubuntu 12.04
JDK (Sun Distrubution 1.7_update 51)
Hadoop 2.2.0 (complied version)
Sqoop 1.99.3 (complied version)
Thank again!
check your 'JDBC Driver Class' of the connection you just created in sqoop,it should be setted
as com.mysql.jdbc.Driver.
If still not work,put mysql-connector-java-3.1.12-bin.jar into $SQOOP_HOME/server/lib

SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbname

I've inherited a project (and I have absolutly no experience of Java) and I'm rather stuck.
We have a server running redhat, which I needed to update one of the jar files. So I simply copied up the updated file and restarted the service for that file. However this process has worked on our other server I did that too but on this one it comes up with the below in the log file.
Exception: com.mysql.jdbc.Driver
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbanme
The jar files are uploaded to a folder in the root of the website and within that jar folder is a lib folder where mysql-connector-java-5.1.6-bin.jar is located.
Does anyone know what I could be missing as I'm a newbie to linux aswell.
Thanks in advance
java.sql.SQLException: No suitable driver found
This exception can have 2 causes:
The JDBC driver is not loaded at all.
URL does not match any of the loaded JDBC drivers.
Since the driver seems to be loaded , it look like that the URL is not valid on that machine:
jdbc:mysql://localhost:3306/dbname
Do you have mysql running and listening on port 3306 on that machine. Also make sure you hte schema dbname there.
You need only set that:
[jdbc:mysql://localhost/dbanme]
instead of
[jdbc:mysql://localhost:3306/dbanme]
Because java compiler default understand a port 3306, so no need to fill "3306" after "localhost:"

Categories

Resources