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.
Related
We are facing issue with the the query timeout property on Db2, it is working when we are running the app in WebSphere, then we moved to Tomcat, this issue was recently caught up by a very long query that hangs very long until timeout after 45 minutes, some pieces of the code we have as below, they haven't been changed since moving to Tomcat:
CallableStatement cs = statementFactory.createCallableStatement(getConnection(), source.getSQL(),
statementConfig);
cs.setQueryTimeout(10);
boolean resultSetAvailable = cs.execute();
if (resultSetAvailable) {
resultSet = cs.getResultSet();
} else {
resultSet = CallableStatementParamsUtils.checkForOutResultSet(cs, storedProc);
}
I set up the timeout to be 10 secs, but it didn't timeout at all, anybody knows why?
The difficulty is Db2 driver is not open source, not able to debug it, How can I solve this issue using Db2?
In this case, the use of a jdbc type 4 driver appeared to help to resolve the issue.
Note that the IBM db2 jdbc driver supports tracing for problem determination as described here.
When dealing with jdbc issues with Db2, it is always helpful to ensure you are using the most recent jdbc driver, available via this page.
From the comments, the previous jdbc driver was a type-2 driver (which supports query timeouts only in specific configurations as IBM documents in the Db2 knowledge center, the notes are copied below).
The various IBM notes on this page concerning queryTimeout support in jdbc are essential reading , viz:
For DB2 for i, this method (setQueryTimeout) is supported only for a seconds value of 0.
For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on Db2 for z/OS, Statement.setQueryTimeout is supported only if
Connection or DataSource property queryTimeoutInterruptProcessingMode
is set to INTERRUPT_PROCESSING_MODE_CLOSE_SOCKET.
For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on Db2 on Linux, UNIX, and Windows systems, Statement.setQueryTimeout is
supported only if Connection or DataSource property
queryTimeoutInterruptProcessingMode is set to
INTERRUPT_PROCESSING_MODE_STATEMENT_CANCEL.
For the IBM Data Server Driver for JDBC and SQLJ Version 4.0 and later, Statement.setQueryTimeout is supported for the following
methods:
Statement.execute
Statement.executeUpdate
Statement.executeQuery
Statement.setQueryTimeout is supported for the Statement.executeBatch
method only when property queryTimeoutInterruptProcessingMode is set
to INTERRUPT_PROCESSING_MODE_CLOSE_SOCKET (2).
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.
I want to create a Persistence Unit in Netbeans, but I can't connect the drivers with a DB2/400 Database. I don't now if something was wrong on AS400 (IBM I) or I'm doing something wrong. I was using 2 drivers to try to connect to the database, but no one works.
These are the error messages:
Using the first driver (db2jcc.jar WITH db2jcc_license_cisuz.jar)
Cannot establish a connection to jdbc:db2://HOST:446/DATABASE using com.ibm.db2.jcc.DB2Driver ([jcc][t4][2057][11264][3.69.24] The application server rejected establishment of the connection. An attempt was made to access a database, DATABASE, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004)
Using the second Driver (db2jcc4.jar WITH db2jcc_license_cisuz.jar)
Cannot establish a connection to jdbc:db2://HOST:446/DATABASE using com.ibm.db2.jcc.DB2Driver ([jcc][t4][2057][11264][3.69.24] The application server rejected establishment of the connection. An attempt was made to access a database, DATABASE, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004)
Are you sure that the "DATABASE" name is correct? I get the same error when
the "DATABASE" not is not correct.
An attempt was made to access a database, GARBAGE, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004
The "DATABASE" name should be the *LOCAL entry seen in WRKRDBDIRE. If you use *LOCAL as the DATABASE name, that should also work.
For connecting to IBM i, an alternative JDBC driver is JTOpen JDBC driver (http://jt400.sourceforge.net/)
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 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.