I am trying to establish connection to SQL Server from eclipse.
I added to the project build path the jar sqlserverjdbc.jar .
This is my code:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//Connection m_Connection = DriverManager.getConnection(
// "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=TMO", "****", "****");
String url = "jdbc:sqlserver://10.25.50.14;databaseName=TMO;integratedSecurity=true";
//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(url);
Statement m_Statement = conn.createStatement();
When I call getConnection(url) I get an error:
Nov 17, 2014 1:08:43 AM com.microsoft.sqlserver.jdbc.SQLServerConnection
SEVERE: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
Exception in thread "main" java.lang.UnsupportedOperationException: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
at com.microsoft.sqlserver.jdbc.SQLServerConnection.(SQLServerConnection.java:238)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.ccih.analytics.clustering.tmo.DexRunner.getKeyPhrasesFromNewNlpDB_W_SAMPLE(DexRunner.java:394)
at com.ccih.analytics.clustering.tmo.DexRunner.main(DexRunner.java:59)
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:838]
Am I using the wrong jar ? I checked my eclipse project in the 'Referenced Libraries' and I saw the entry of the related jar with all the .class files
Yep You are Using the wrong jar which is not compatible for your JRE. I had same problem and i tried using the sqljdbc4.jar library and it worked completely fine for me.You can download .jar from here.DOWNLOAD
i hope this helps.
Related
I have tried to install the ODBC driver 18 for SQL Server in my symfony project. I am getting the following error messages. I wanted to ask if anyone could knows the solution for these.
An exception occurred in the driver: SQLSTATE[08001]: [Microsoft][ODBC
Driver 18 for SQL Server]SSL Provider: [error:16000069:STORE
routines::unregistered scheme:scheme=file][error:80000002:system
library::No such file or direc tory:calling
stat(/usr/local/etc/openssl#3/certs)][error:16000069:STORE
routines::unregistered scheme:scheme=file]
Environment details:
symfony version: 5.4.16
php8.1
Homebrew 3.6.16
apache 2.4.54
#AlwaysLearning's answer did help me.From the article linked, I checked the openssl#3 folder and I did see there was a cert.pem file. I then created a certs directory and copied the cert.pem file into that directory. That got of rid of my error message.
I did encounter an additional issue where I needed to add TrustServerCertificate parameter to the end of my connection string that is used to connect to the SQL server.
;TrustServerCertificate=1
I am developing my application in SpringBoot which uses liquibase to update my ms-sql database.
This worked fine till now, but now I am trying to update everything to the latest version:
I changed java from 15 to 17.
I also updated liquibase-maven-plugin to 4.5.0.
mssql-jdbc dependency for liquibase is: mssql-jdbc:9.4.0.jre16
The new mssql-jdbc_auth-9.4.0.x64.dll file is moved to this folder:
c:\apps\Java\x64\jdk-17\bin\ (this is my java location).
My IntelliJ is set to use java 17 (JAVA_HOME is also configured to
the 17 path)
the version of Microsoft SQL Server Express (64-bit): 11.0.2100.60
So I think I did everything, but still, when I try to run my maven, I get the following error:
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.5.0:update (myDatabase) on project my-project:
[ERROR] Error setting up or running Liquibase:
[ERROR] liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:sqlserver://localhost:1433;databaseName=My_Database;integratedSecurity=true with driver com.microsoft.sqlserver.jdbc.SQLServerDriver. The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]"
I am configuring Tibco EMS 7.0 server on Solaris 10 from the default file based store to a Database Store (Oracle RAC). Starting the instance the log shows the following JVM error:
2014-09-18 14:34:36.729 Logging into file '/lcl/dev/logs/tibco/jmspm2.log'
2014-09-18 14:34:36.729 ERROR: Error Loading JVM: ld.so.1: tibemsd64: fatal: /lcl/dev /apps/tibco/components/eclipse/_jvm/lib/sparc/libjvm.so/lib/sparcv9/server/libjvm.so: Not a directory
I have installed hibernate 3.2.5.001 from Tibco that uses the Eclipse JVM and files. Also istalled the recommended instantclient_11_2 that includes ojdbc5.
Below is my modified tibemsd.conf with dbstore_classpath, dbstore_driver_name, dbstore_driver_dialect, jre_library as:
dbstore_classpath = /lcl/dev/apps/tibco/components/eclipse/plugins/com.tibco.tpcl.org.hibernate_3.2.5.001/hibernate3.jar;/lcl/dev/apps/tibco/ems/7.0/bin/dom4j-1.6.1.jar;/lcl/dev/apps/tibco/ems/7.0/bin/commons-collections-2.1.1.jar;/lcl/dev/apps/tibco/ems/7.0/bin/commons-logging-1.0.4.jar;/lcl/dev/apps/tibco/ems/7.0/bin/ehcache-1.2.3.jar;/lcl/dev/apps/tibco/jta.jar;/lcl/dev/apps/tibco/ems/7.0/bin/cglib-2.1.3.jar;/lcl/dev/apps/tibco/antlr-2.7.6.jar;/lcl/dev/apps/tibco/ems/7.0/bin/antlr-2.7.6.jar;/lcl/dev/apps/tibco/components/eclipse/plugins/com.tibco.tpcl.org.com.mchange.c3p0_0.9.1.001/c3p0-0.9.1.jar;/lcl/dev/apps/tibco//ems/7.0/bin/asm.jar;/lcl/dev/apps/tibco/asm-attrs.jar;/lcl/dev/apps/tibco;../db_components/instantclient_11_2/ojdbc5.jar
dbstore_driver_name = oracle.jdbc.driver.OracleDriver
dbstore_driver_dialect = org.hibernate.dialect.Oracle10gDialect
jre_library = /lcl/dev/apps/tibco/components/eclipse/_jvm/lib/sparc/libjvm.so
I get the same error when I installed jdk1.5.0_71 and attempted to call ./jdk1.5.0_71/jre/lib/sparc/libjvm.so
I get the same error when set jre_library to: /lcl/dev/apps/tibco/components/eclipse/_jvm/lib/sparc since it appears to be looking for a directory.
Questions:
Is the ld.so.1 libray required (can't find it)?
Any ideas how to resolve this error and configure Java?
Solved!
I installed Java 1.6 via jdk1.6.0_45 and it worked! Below are the JRE settings that were used.
# jre_library = "/lcl/dev/apps/tibco/jdk1.6.0_45/jre/lib/sparcv9/server/libjvm.so" # This also works
jre_library = "/lcl/dev/apps/tibco/jdk1.6.0_45/jre" # This path works too, more consise
jre_option = -Xmx256m
I am trying to access MS SQL server 2005 from a servlet file. I am using JDBC 4.0 driver.
I have already added the JAR files sqljdbc.jar and sqljdbc4.jar files to my Tomcat /lib folder.
But while running code I am getting an error
HTTP Status 500 - Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
How is this caused and how can I solve it?
My code is:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = conn = DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=school;user=sa;password=123");
PrintWriter pwOut = res.getWriter();
pwOut.println("Connected");
Statement st = conn.createStatement();
String searchCriteria = req.getParameter("txtSearch");
ResultSet rs = st.executeQuery("select * from student");
res.setContentType("text/html");
The error message is pretty clear. Tomcat is using the wrong driver.
You state that you copied sqljdbc.jar and sqljdbc4.jar into the Tomcat lib folder. That is most probably the reason for your problem.
You only need sqljdbc4.jar otherwise Tomcat picks up the wrong one.
Try to delete sqljdbc.jar from the Tomcat lib folder
Here is my Code to connect java to Microsoft sql Server 2012
You only need sqljdbc4.jar that avail on offical Microsoft website. Here is the link:
http://download.microsoft.com/download/0/2/A/02AAE597-3865-456C-AE7F-613F99F850A8/sqljdbc_4.0.2206.100_enu.exe
It contains 2 jar files, and I am trying to use sqljdbc4.jar. This is the code I am using to connect:
package com.Sql.ConnectDB;
import java.sql.*;
public class DbClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
**String url="jdbc:sqlserver://localhost;databaseName=Student";**//important
String user="username";
String pass="password";
**Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");**//important
Connection con=DriverManager.getConnection(url,user,pass);
System.out.println("Conneccted Successfully");
}catch(Exception e){
e.printStackTrace();
}
}
}
I'm using ubuntu 9.10 and I installed java and tomcat using the package manager. When I went to run startup.sh, it first complains about catalina.out not being there and not being writable. I fixed that and it doesn't complain about that (why isn't that included in the install??) Now it's complaining about server.xml not being there when I shut down the server. Here is my output from command line:
user#desktop:/usr/share/tomcat6$ ./bin/startup.sh
Using CATALINA_BASE: /usr/share/tomcat6
Using CATALINA_HOME: /usr/share/tomcat6
Using CATALINA_TMPDIR: /usr/share/tomcat6/temp
Using JRE_HOME: /usr/lib/jvm/java-6-sun-1.6.0.15
user#desktop:/usr/share/tomcat6$ ./bin/shutdown.sh
Using CATALINA_BASE: /usr/share/tomcat6
Using CATALINA_HOME: /usr/share/tomcat6
Using CATALINA_TMPDIR: /usr/share/tomcat6/temp
Using JRE_HOME: /usr/lib/jvm/java-6-sun-1.6.0.15
Dec 11, 2009 4:42:57 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.io.FileNotFoundException: /usr/share/tomcat6/conf/server.xml (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:407)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:337)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
user#desktop:/usr/share/tomcat6$
I'm really new to tomcat so this might be a dumb question, but why isn't there a sample server.xml in a fresh install of tomcat? What can I put in there to shut it up... even if its just a stub and a +1 to any one who can explain to me the structure of this file?
Try using server.xml located at:
/etc/tomcat6/server.xml
server.xml is the configuration file for the application server. It contains stuff like what port is the server going to listen at, where are the applications being deployed, and other related stuff.
More info on Tomcat in Ubuntu:
https://help.ubuntu.com/12.04/serverguide/tomcat.html