I'm trying to run some application and get the following error:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Can't start a cloned connection while in manual transaction mode.
I know that I should add the parameter ;SelectMethod=Cursor to your JDBC URL
But I'm having problem understanding where exactly should I change it? Should it be some conf file in JDBC driver folder somewhere? Or can I do it from sql management studio?
Also is there some easy way to determine if and what version of JDBC driver I have?
Help is very much appreciated!
You specify the URL when creating your JDBC connection, e.g.:
Connection con = DriverManager.getConnection(
"jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]",
username,
password);
Of course you have to replace the stuff in the brackets with your values.
Quite the same is true for every other tool (e.g. IntelliJ, Eclipse) I know of that connects to a DB via JDBC. See e.g. attached screenshot. Here you also specify the connection parameters via the JDBC URL.
Related
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 am trying to connect to a db2 database in Java. Below the driver and the connection string and the driver details i am giving
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
String url="jdbc:db2://hostname:portnumber/databasename";
sourceConnection=DriverManager.getConnection(url,"username","password");
But I am getting the below exception
"COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0615E Error receiving from socket, server is not responding. SQLSTATE=08S01"
I also tried changing the connection string to
String url="jdbc:db2:hostname:portnumber/databasename";
Still it is resulting the same exception above while trying to get the Connection.
And i have tried the below option also using JDBC app driver
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
DB2DataSource db2ds = new DB2DataSource();
db2ds.setServerName("hostname");
db2ds.setPortNumber(portnumber);
db2ds.setDatabaseName("databasename");
db2ds.setUser("username");
db2ds.setPassword("password");
sourceConnection=db2ds.getConnection();
For the above two connection I used the jar "db2java.jar"
And i have tried using the JCC driver:
Class.forName("com.ibm.db2.jcc.DB2Driver");
String url="jdbc:db2://hostname:portnumber/databasename";
sourceConnection=DriverManager.getConnection(url,"username","password");
For this connection i have added the below jars
1)db2jcc.jar
2)db2jcc_license_cu.jar
This time around I am getting the below error,
"com.ibm.db2.jcc.am.go: [jcc][t4][201][11237][3.57.82] Connection authorization failure occurred.
Reason: Security mechanism not supported. ERRORCODE=-4214, SQLSTATE=28000"
I tried to connect to the same db2 source using "Quest for DB2" tool and the connection was successful.
Am i missing something in the code and is it a problem with DB2 drivers or connection string?
Can someone please guide me.
Thanks in advance.
Cause:
If the DB2® instance where InfoSphere Optim Performance Manager is running has the authentication configuration parameter set to DATA_ENCRYPT, you cannot log in to the web console.
Resolving the problem:
Do the following steps:
On the DB2 instance where Optim Performance Manager is running, set the authentication configuration parameter to SERVER by issuing the following command:
db2 update dbm cfg using authentication server
Restart the DB2 instance and InfoSphere Optim Performance Manager.
For more details visit here.
Your first two attempts were not supposed to work. You're using the JCC driver URL format, so it wouldn't be valid for either "net" or "app" drivers, which are deprecated anyway.
Use the JCC driver (com.ibm.db2.jcc.DB2Driver) and the URL format of "jdbc:db2://hostname:portnumber/databasename" and see this technote for the solution to the "Security mechanism not supported" problem. In short, you need to use a supported JDK.
I am trying to establish a connection to a MySQL database to read and write data.
However, I get an error when trying to run this code:
public void openConnection() throws SQLException {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/jared_bookoo", "root", "pass");
Statement stmt = conn.createStatement();
}
The weird thing is, all my tests pass when I run a JUnit test. I am able to read from the database correctly and return the correct data. However, once I hook it up to a JSP and try to read it from a locally hosted webpage, I get the following error:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/jared_bookoo
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at jared.simpledatabase.DBInterface.openConnection(DBInterface.java:42)
...
What is happening, and how can I fix it? The driver is installed (and working; I can read from the database in my tests), so I don't see what could be going wrong.
Put the MySQL driver jar in your WEB-INF/lib library. You can find it here. Also, make sure that when you generate the war file, the MySQL driver jar is in web_app_name/WEB-INF/lib.
Another advice (just in case since you don't specify where you call that method): You should never try to use Java code directly in your JSP. For further info, refer to How to avoid Java code in JSP files?.
One more advice, in real world web applications, you would use a Data Source to get the Connection. Since you don't specify which application server you use, I'll let an example about configuring the Data Source in Tomcat 7.
I want to access a database using a connection string that is given by a third party application. I have one example configuration that has a connection string like the following:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\path\to\theDatabase.mdb;Persist Security Info=False
Calling
DriverManager.getConnection("jdbc:odbc:" + connectionString);
gives me an SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
The third party application can access the database without problems.
The OS is Windows XP Service Pack 3 and up to date.
The msjet40.dll in system32 folder has version 4.0.9511.0 (up to date according to http://support.microsoft.com/kb/239114/en-us)
The file exists and I can access it using jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};C:\path\to\theDatabase.mdb
I just don't know what I'm doing wrong.
Problem is in your odbc connection
To connect access database try following
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:connSource");
goto ControlPanel->AdministrativeTools->DataSource(ODBC)->System DSN->ADD->MicrosoftAccess->
then in the name field give the Source Name as connSource.
you have to use this name instead of database name in your DriverManager.getConnection method.
Because getConnectionMethod take the source name not the database name. so your code is not working.
This might be a problem. I don't know of any JDBC drivers for OLE DB data sources. Here on SO this questions sits without answers from March: https://stackoverflow.com/questions/5184046/jdbc-oledb-bin .
Refer to the wesite below it contains connection strings of all variants for all the databases
http://www.connectionstrings.com/
I have a problem in establishing DB2 connection with wrong user-name/password. We have an application which runs on LAN on many systems using DB2 database located on my system as well as other systems.
Firstly I use this URL to create other system DB2 connection:
Connection con = DriverManager.getConnection("jdbc:db2://Rahulkcomputer:50000/XAN4", "rahulk", "dbirs#35");
this returns proper Connection object. Now when I change the URL to access my system DB2 connection with same user-name/password as (using same user-name/password is intensely done for checking error handling):
Connection con = DriverManager.getConnection("jdbc:db2://127.0.0.1:50000/XAN4", "rahulk", "dbirs#35");
This time it again returns the Connection object instead of throwing an SQLException specifying wrong user-name/password (due to my system's DB2 authentication is totally different from Rahulkcomputer's system)
After getting connection, I execute this query to check proper user name as explained in post:
Simple DB2 Query for connection validation
SELECT CURRENT SQLID FROM SYSIBM.SYSDUMMY1
(this returns "rahulk" in both cases)
Why DB2 created connection in 2nd case with wrong user-name/password (moreover when we close all the services of DB2 on Rahulkcomputer, even then I get the connection in 2nd case)?
Thanks in Advance.
You either created your database with the restrictive option or revoked the select right to sysibm from PUBLIC. The connection you had was fine, the access rights not. 42704 is DB2's way of saying "huh?", it did not recognize sysibm because you had no rights to see it.