I am trying to connect to Microsoft SQLServer 2012 through Java. I have tried using the Microsoft supplied jdbc driver, as well as the jtds driver.
However, whenever i try to load either of the drivers, I get a "No suitable driver found" exception.
The connection URL i have is:
jdbc:jtds:sqlserver://localhost:1433/mineDB;instance=SQLServer2012;integratedSecurity=true;USENTLMV2=true
The driver class name:
net.sourceforge.jtds.jdbc.Driver
I have loaded the jtds.1.3.1.jar file into my classpath system variable, and when trying to use the windows jdbc driver i did the same
EDIT:
Forgot to mention. the driver is called using Class.forName().
Everything is being done on one machine at the moment, and once it is all working i'm going to see if i can get an external database connection working
Related
I have a .mdb database and I'm trying to design a report using JasperSoft Studio 6.3.0 (Eclipse plug-in).
In my Java Application I have used the UCanAccess JDBC Driver to build the connection as JDBC-ODBC Bridge is no longer supported in Java 8.
When creating the Data Adapter, I chose "Database JDBC Connection", and then, as UCanAccess is not in the default list of Drivers, I added the .jar file with the UCanAccess Driver.
Screenshot from the Classpath:
Then, I wrote the Driver Class in JDBC Driver (note: the standard action is to choose one of the drivers in the combobox, but as I had to add it manually, I read somewhere in the Internet that I must write it by myself).
Screenshot from the Driver setting:
When I test the connection, it will stay loading forever and will never end.
NOTE: the database has no user/pass. I successfully connected the database to my Java application (using the UCanAccess Driver); my problem is with the connection to the report.
What can I do? Any suggestions? Thanks!
I managed to solve my question by myself. I also had to add the four .jar in UCanAccess-x.x.x-bin>>lib to the Classpath (commons-lang, commons-logging, hsqldb, jackcess)
I'm trying to deploy a JBoss webapp that requires selectMethod=cursor in the jdbc driver connection string.
But when I try connecting to my mssql (2008) database with this in the string, it just timesout when connecting. When I remove selectMethod=cursor from my connection string, it works/connects, but my app doesn't work and gives me this error: [SQLServer JDBC Driver]Can't start a cloned connection while in manual transaction mode.
I have already updated my jdbc driver - tested all versions.
Here is my connection string:
jdbc:microsoft:sqlserver://127.0.0.1:1434;DatabaseName=xxxx;user=xxxx;password=xxxxx;selectMethod=cursor
Thanks.
I switched from using a microsoft jdbc driver to jtds jdbc driver and it works wonderfully again.
Do the Microsoft docs on the issue shed any light on this?
This error occurs when you try to execute multiple statements against a SQL Server database with the JDBC driver while in manual transaction mode (AutoCommit=false) and while using the direct (SelectMethod=direct) mode. Direct mode is the default mode for the driver.
Resolution is:
When you use manual transaction mode, you must set the SelectMethod property of the driver to Cursor, or make sure that you use only one active statement on each connection as specified in the "More Information" section of this article.
I would like to access to a Oracle database (SQL Developer) from a Java program. I never used JDBC before.
Here is what i wrote:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:host_name:port:database_name";
Connection con = DriverManager.getConnection(url, login, passwd);
I got an error:
[Microsoft][ODBC Driver Manager]
Data source name not found and no default driver specified
Host name, port, DB name and logins are good.
Is this driver OK to communicate with SQL Developer ?
I don't know what to do,
thanks for helping !
Try this
Class.forName ("oracle.jdbc.driver.OracleDriver");
for Oracle you can use ojdbc
Class.forName("oracle.jdbc.driver.OracleDriver");
for SQL Server u can use jtds
Class.forName("net.sourceforge.jtds.jdbc.Driver");
The JDBC driver sun.jdbc.odbc.JdbcOdbcDriver is bridge driver that wraps an ODBC driver as described here.
SQL Developer is an Oracle tool that acts as an IDE against the Oracle database.
To connect Java to an Oracle database you should obtain the Oracle JDBC driver and ensure the jar is on your classpath (as described in the documentation for java.sql.DriverManager, forcing the class to be loaded is no longer necessary).
The important bit is the connection string, which in its simplest form for Oracle should follow the structure:
jdbc:oracle:thin:#//host:port/service
Where:
host: the hostname of the machine running Oracle
port: the port that Oracle is listening for connections on
service: the database instance to connect to
The full docs are here.
I am trying to connect to an sqlite database using Rjb and the JDBC driver from https://bitbucket.org/xerial/sqlite-jdbc#markdown-header-usage
I cannot work out how to call the following Java using Rjb:
Class.forName("org.sqlite.JDBC")
Has anyone connected to sqlite using Rjb with success?
The RJB code I have so far is as follows and is throwing the exception 'java.sql.SQLException: No suitable driver found for jdbc:sqlite:/Users/obrientimothya/Dropbox/development/vle/db/development.sqlite3'
Connection = Rjb::import 'java.sql.Connection'
DriverManager = Rjb::import 'java.sql.DriverManager'
SQLException = Rjb::import 'java.sql.SQLException'
DriverManager.registerDriver(Rjb::import('org.sqlite.JDBC'))
connection = DriverManager.getConnection("jdbc:sqlite:/Users/obrientimothya/development.sqlite3")
I ended up solving this by adding the system property jdbc.drivers when loading the JVM...
Rjb::load( classpath, ['-Djdbc.drivers=org.sqlite.JDBC','-Xms128M', '-Xmx256M'] )
This tells java.sql.DriverManager to load the sqlite jdbc driver class itself, eliminating the need for a Class.forName() call.
I need to develop an application that connects to various DSN's using the Microsoft ODBC drivers. I have developed the application in Eclipse and it seems to work properly. The connection succeeds and I am able to view table data.
However when I export the project to a runnable jar file (using Eclipse) the functionality fails for Oracle. It is unable to establish connectivity with the Oracle connection string. It still works for SQL server but fails in case of Oracle. I'm unable to figure out the cause as the same ODBC drivers are being used for both Oracle and SQL-Server. More mystifying is that it runs properly on Eclipse. Since im using the ODBC drivers I don't believe the problem is because of an external jar file.
The driver is sun.jdbc.odbc.JdbcOdbcDriver and connection string is like jdbc:odbc:oratest;user=fell;password=pass.
I'm getting the following exception
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
Can you please help me figure what the problem might be?
Thanks in advance,
Fell
Create a System DSN.
java.sql.Connection cn;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=java.sql.DriverManager.getConnection("jdbc:odbc:dsn_name","user","pass");
Check the classpath in the eclipse project