I'm trying to get a large result set to stream and having no luck. The MySQL docs are somewhat unclear as to whether this should even work. E.g.:
When using versions of the JDBC driver earlier than 3.2.1, and connected to server versions earlier than 5.0.3, the `setFetchSize()` method has no effect, other than to toggle result set streaming as described above.
I'm using MySQL 4.1.19 with Connector/J 5.1.6. My code is basically:
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);
stmt.executeQuery(“select * from huge_table”);
Are streaming result sets possible with MySQL 4.1.x? And if so, how?
What you are looking for is called "unbuffered query" in MySQL lingo, but a quick search seems to indicate that:
MySQL only supports it starting from version 5.0
JDBC doesn't support it
Related
I want to connect to an old Oracle9i Release 9.2.0.4.0 database with SQLDeveloper 21.4.3 and I followed this answer How to change default JDBC driver of Oracle SQL Developer?.
The difference is just the versions of SQLDeveloper (21 instead of 20) and Oracle Instant Client (21.3 instead of 11.2.0.4.0). In my case both are the latest ones.
My OS is also Windows 10, 64bit.
Testing the client and connection as described are successful. But when actually connecting to the database SQLDeveloper hangs and can only be closed by TaskManager.
I tried both connection types: simple and with user defined URL jdbc:oracle:thin:#172.31.10.3:1521:LZH. This URL works in other applications like SQL Workbench/J using oracle driver ojdbc14_g.jar.
I also tried to set this jar file in SQLDeveloper preferences as external jdbc driver. But I guess here only non oracle drivers like postgreSQL make sense, but don't know. It doesn't make a difference anyway.
Thanks for any suggestion!
You cannot connect an Oracle Client version 21 to an (more than 20 years old) Oracle 9i database. See Client / Server Interoperability Support Matrix for Different Oracle Versions
Maybe ask Oracle support to get an older version of SQL Developer.
Oracle provided me a link for older
Instant Client Versions.
Version 11.2 works fine with SQLDeveloper 20.2.
SQLDeveloper 21 only supports client versions 19 and higher.
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).
My application runs select sql queries using JDBC driver on Oracle and stores the data in Result set. Then by using buffer writer/file writer writes information to xml.
** Weird Behaviour : Same code when runs with Oracle 11g takes 2 hrs to complete and for 12 C it takes # 12 hrs.
** JDBC driver I am using is compatible with 11g and 12c. Data is same on both the DBs. Both DB are independent instance, so no question of migration problems.
Can somebody please help, what how can I debug for this ?
** select queries uses bind parameter IN clause and has 1000 values in it.
IT seems, there is a bug with Oracle 12C. Working with Oracle support.
I have a Cassandra process that was created and defined in early Cassandra versions. So far, we used an hector driver to connect to it. Im in a process of changing the driver to DataStax to enjoy the CQL new features and to allow asynchronous access.
I encounter some problems in the process of doing that transition. I've read this upgrade guide which shed some light though I still encounter some problems.
The biggest one is that I cant access the keyspace with a protocol version bigger than one. When I try the following python code:
cass4 = Cluster(['MyIp'])
cass4.protocol_version = 2
session = cass4.connect('myKeySpace')
This code yields the following errors and warnings:
ERROR:cassandra.connection:Closing connection <AsyncoreConnection(4849045328) IP:9042> due to protocol error: code=000a [Protocol error] message="Invalid or unsupported protocol version: 2"
WARNING:cassandra.cluster:Downgrading core protocol version from 2 to 1 for IP
WARNING:cassandra.metadata:Building table metadata with no column meta for keyspace
With the Java driver, I simply get a NoHostAvailableException: All host(s) tried for query failed connection error if im trying to connect with a protocol version bigger than 1.
This connection problem is causing me a lot of trouble building an appropriate Java DAO. for example, if Im trying to do batch update, e.g.:
BatchStatment batch = new BatchStatement()
batch.add(somePreparedStatement)
cqlSession.executeAsync(batch)
I get the following error:
com.datastax.driver.core.exceptions.UnsupportedFeatureException: Unsupported feature with the native protocol version 1 (which is currently in use): Protocol level batching is not supported
Running a "BEGIN BATCH.." operation directly on a cluster node using cqlsh works, So I know this CQL command can be executed, but I dont know how to prepare it in Java and execute it with protocol version 1. Also, the cassandra and CQL version an the cluster seems appropriate:
[cqlsh 3.1.7 | Cassandra 1.2.13.2 | CQL spec 3.0.0 | Thrift protocol 19.36.2]
So, questions are:
Why is this happening?
Can I connect to that keyspace with a protocol version greater than 1?
If not, Can I somehow bypass this batch update problem?
The answer for this issue was eventually found here:
Can I combine Batches and PreparedStatements?
Starting with Cassandra 2.0 and the corresponding versions of the C#,
Java, and Python drivers, PreparedStatements can be used in batch
operations (nb before that you could still prepare a complete batch
operation, but you’d need to know apriori the number of statements
that will be included).
Since my Cassandra version is 1.2xx, I cant use batch updates and prepared statements.
A work around is to create the query as a string (Ya, that's dirty) and than execute the string query.
I'm currently working on a java program that will access an Microsoft SQL Server using the JDBC-ODBC bridge driver provided in the Java distribution.
Everything seems to be setup correctly and I can query basic data from the database, but when I try to run a query that gets a UniqueIdentifer field in it, when I do the subsequent ResultSet.getString() it fails with:
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Numeric value out of range
Has anyone experienced anything like this before? This works using the JDBC driver provided by Microsoft, but the customer wants to use the DSN they created.
If this is helpful when I run a Connection.getMetaData(); the UniqueIdentifer field returns a DATA_TYPE of 1111
If you call a batch of two or more Microsoft SQL Server stored procedures by using the ODBC Driver for SQL Server and by using the ODBC canonical {call X} method, you may receive the following error message from the driver:
Numeric Value Out Of Range
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft SQL Server 2000 Service Pack 3.