jdbc

ResultSet -> XLS

I have to run few SQL queries and put the results into a spreadsheet. Since I am on a Spring/Java environment, I was about to run the queries using JDBC, iterate through the ResultSet, and use Jakarta POI to create a simple XLS. This looks like a very common requirement, so I was wondering if there is something already available - a pac...

Jython zxJDBC cursor.tables() always returns None

I am using Jython 2.2.1 and MySQL Connector/J 5.1 to access a MySQL database. I would like to use zxJDBC's cursor.tables() method to retrieve a list of tables in that database. However, this method always returns None. According to the zxJDBC documentation, cursor.tables() is the same as Java's DatabaseMetaData.getTables(). When I cal...

Building resultset using collection object

Hi, I had an issue in building the resultset using java. Here it goes... I am storing a collection object which is organized as row wise taken from a resultset object and putting the collection object(which is stored as vector/array list) in cache and trying to retrieve the same collection object. Here i need to build back the resultse...

Can someone explain this JDBC Exception to me?

I'm gettting the following exception when performing an insert to an Oracle Databse using JDBC. java.sql.SQLRecoverableException: Io exception: Unexpected packet What could cause this and how can I recover from it? The application I'm writing performs an aweful lot of updates the the databse in rapid succession. Judging from the exce...

Is Spring too complex for JDBC operations?

Just been looking at the Spring framework for JDBC - it looks like there is a bit of a learning curve - and I'm still not able to find a nice up to date quick start Spring/JDBC tutorial of any quality! Is there something lighter than Spring for basic JDBC operations - or has anyone got any good links for tutorials Many thanks ...

Number of sockets available for a JDBC connection at Windows 2003

My team built a Windows Service in Java that connects to a SQL Server 2005 in a Windows 2003 Server, using pure JDBC (no connection pooling) with the JTDS driver. After a while, the method that opens the connections to the database start raising exceptions with the following stack trace: java.net.BindException: Address already in u...

How to "name" a query in postgres

In postgresql a query in the querylog gets something like this: 2009-02-05 00:12:27 CET LOG: duration: 3781.634 ms execute <unnamed>: SELECT QUERY .... Is there a possibility to put something more usable into the "< unnamed >" placed like the url the query was requested from? Are there any other possibilities to track the origin o...

Connection pooling options with JDBC: DBCP vs C3P0

What is the best connection pooling library available for Java/JDBC? I'm considering the 2 main candidates (free / open-source): Apache DBCB - http://commons.apache.org/dbcp/ C3P0 - http://sourceforge.net/projects/c3p0 I've read a lot about them in blogs and other forums but could not reach a decision. Is there any relevant altern...

Hibernate's setFirstResult() issue with Oracle jdbc driver

I'm trying to do pagination with Hibernate using setFirstResult() and setMaxResults() but I'm not getting the expected results when setting the first result to 0. When doing the following: Query query = session.createQuery(queryString); query.setFirstResult(0); query.setMaxResults(30); List list = query.list(); //list.size() r...

Duplicate set of columns from one table to another table

My requirement is to read some set of columns from a table. The source table has many - around 20-30 numeric columns and I would like to read only a set of those columns from the source table and keep appending the values of those columns to the destination table. My DB is on Oracle and the programming language is JDBC/Java. The source...

Implementing support for nested transactions using JDBC 3.0

Hi all, our legacy application uses JDBC 3.0. it supports transactions by implementing its own transaction manager that is capable of returning the same JDBC connection for each thread. The problem I recently discovered is that it doesn't support nested transactions: if a transaction is started inside an another transaction, then every ...

What is difference between autoReconnect & autoReconnectForPools in MySql connector/J ?

In the configuration reference for MySql's connector J driver, a caveat emptor is issued on the use of the autoReconnect property. I followed the instructions and increased my server's *wait_timeout*. Since I am using DBCP (I am considering moving to c3po after reading several posts on Stackoverflow shooting down DBCP ), is it ok to use ...

JDBC and Connection Pools in Glassfish App Server

I want to set up a connection pool and JDBC connection on EAR deployment so I do not have to set it up on each App Server I deploy to manually. What do I need to do? Is there an .xml file I can put this information into? ...

jSecurity JDBCRealm SQL setup

Hello all! I am trying to use jSecurity for an enterprise java app, but the documentation is...well...lacking. Has anyone out there in SO-land been able to get the JDBCRealm setup, and if so did you find a SQL setup script or did you just derive it on your own? Either way, can you provide the create SQL statements to make this work? ...

How do you make sql server jdbc calls to stored procedure use a server side cursor?

I am using JDBC to call a stored procedure in MSSql 2005. I would like to have the result set make use of server side cursors to limit the amount of memory used by the client. I am able to do this easily using a simple query and setting the SelectMethod=cursor on the connection. When I put that query in a stored procedure, it appears ...

Running / compiling jdbc-sqlite on OSX 10.5

I can't for the life of me get the library located here: http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC and zentus.com to run in native (JNI) mode on OSX 10.5. If I query the driver for the mode it always says "pure", which means it's running in nested VM mode and pure java code is running to query the sqlite database, which is slower...

Is JDBC Connection aquiring with MySQL slower than with e.g. Derby ?

I use Tomcat C3p0 (JNDI configured inside Tomcat) MySQL(InnoDB) / Derby(not embedded) as Database EHCache (in Memory) Hibernate Testmachine runs WinXP I used Derby for development and wanted to switch to MySQL. I was surprised to see, that with MySQL my Tests were app. 50% slower than with Derby. My Testscenario : app. 2000 Selec...

Check if a column is auto incremented in Sybase with JDBC

To check if a column is auto incremented i can do the following Connection con = ... DatabaseMetaData meta = con.getMetaData(); ResultSet metaCols = meta.getColumns(catalog, schema, table, "%"); while ( metaCols.next() ) String value = rs.getString("IS_AUTOINCREMENT") ... works fine except with Sybase databases. I've...

How to do simple Spring JDBC transactions outside the IoC container?

The project I'm working on uses straight JDBC data access in all its boilerplate glory and doesn't use any transactions. I feel like using transactions and simplifying the way data access methods are written is important, especially with some changes being made currently. The project has been around for quite a while and isn't suited to ...

What are the steps for connecting jdbc with mysql

I'M NOT ASKING ABOUT THE CODE. I just want to know what are and all the steps involved in the connection other than coding. I'm using j2sdk1.4.0 and MySQL Server 4.1. Am very new to this area. Thanks in advance ...