jdbc

Using sqlitejdbc with multiple processes

Hi... I'm trying to run several instances of a program accessing a sqlite database in java (always the same file) and actually I don't know whether it's possible or not that several jobs access the same database.... ...

How to enable GUI behaviors for sorting a JTable when SQL does the sorting?

How do I enable JTable icons and behaviors for sorting table rows by a column, without letting it use a comparison predicate to do the sorting? That is to say, how do I tell the table headers to show the arrow for ascending/descending sort order in the column being used, and get it to call appropriate methods when sort order/column chan...

Regular expressions in JDBC

I have a java-application using JDBC for database interaction. I want to do a search based on a series of regular-expressions, however the application should be generic, we do not know if the database-engine will by mysql,oracle,sql server etc, but we are pretty sure it's gonna be either mysql or oracle. Will regular-expressions limit m...

SQL connection lifetime

I am working on an API to query a database server (Oracle in my case) to retrieve massive amount of data. (This is actually a layer on top of JDBC.) The API I created tries to limit as much as possible the loading of every queried information into memory. I mean that I prefer to iterate over the result set and process the returned row o...

How to stub/mock JDBC ResultSet to work both with Java 5 and 6?

Hi, I'm testing some of my classes working with JDBC statements etc and now I got problem with JDBC ResultSet interface: The software should run both with Java 5 and Java 6 and hence the tests should also be run with both versions. Unfortunately Java 6 has introduced a bunch of new methods (which is still not a big deal) that return a ...

When accessing a database over JDBC/ODBC should you create and close the connection for each request?

If you have a class that services requests from other classes for database data when should you hold onto the databse connection and when should you close it and reopen it on the next request? What if it's a service that responds to connections from external applications? (Web service, Ajax, rpc) Is it a good idea to hold a singleton c...

Can a JBoss JDBC connection be invalidated so that it doesn't get resupplied from the connection pool?

I have a circumstance where a JDBC connection places the Oracle session to which it is attached into a particular state (i.e. DBMS_FLASHBACK enabled mode). It's possible for the exit of this mode to fail (at least theoretically) which means that the session is left in the state erroneously. In this case, the connection can be returned to...

Overhead with Microsoft JDBC driver when executing a stored procedure

I am using Microsoft JDBC Driver 2.0 with SQL Server 2005. To explain my question better, let me start with a sample code to call a stored procedure. public static void executeSproc(Connection con) { CallableStatement cstmt = con.prepareCall("{call dbo.getEmployeeManagers(?)}"); cstmt.setInt(1, 50); ResultSet rs = cstmt.executeQ...

Weblogic Error - Method not supported : Statement.cancel

I am running an application on Weblogic 9.2 MP3, currently having problem with connection pool. ERROR - UserBean retrieving user record. weblogic.jdbc.extensions.PoolLimitSQLException: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool MyApp Data Source to allocate to applications, please incr...

JDBC Batch Update Problem

Hi, I have a slightly unique requirement with the Java-JDBC API along with Oracle Database. I have autoCommit to be default which is true for Oracle and I am using the example similar to this link. However, when I add say 1000 batches and lets say each of them are inserts. And Let us assume that about 20 records violated some constraint...

How to simulate a DB for testing (Java)?

Hi, I'm programming in Java and my applications are making a lot of use of DB. Hence, it is important for me to be able to test my DB usage easily. What DB tests are all about? For me, they should supply two simple requirements: Verify SQL syntax. More importantly, check that the data is selected/updated/inserted correctly, according...

Multiple dynamic data sources for a servlet context

I'm developing a java servlet web application that manages information from multiple databases (all structurally the same) each corresponding to a different "business". The user selects "the current business" which is stored in the session and the application can display or modify that "current business". I would like to use tomcat ...

Which approach is better performance-wise? (with regard to the usage of variable parameter markers in prepared statement in JDBC)

My objective is to get the DeptNames of certain employees from the Emp table. But the number of employees is varying. Please tell if the below approach is correct and which of the below approach is better performance wise. Or is there a better way to go about it? PreparedStatement pstmt = conn.prepareStatement("SELECT Dept from Emp WHER...

Out of Memory allocLargeObjectOrArray from ResultSet

I'm using JDBC to get a large amount of data. The call completes successfully, but when resultSet.next() is called, I get the following error: java.lang.OutOfMemoryError: allocLargeObjectOrArray - Object size: 15414016, Num elements: 7706998 I've attempted to increase the JVM memory size, but this does not fix the problem. I'm not sur...

Is it possible to use GROUP BY with bind variables?

I want to issue a query like the following select max(col1), f(:1, col2) from t group by f(:1, col2) where :1 is a bind variable. Using PreparedStatement, if I say connection.prepareStatement ("select max(col1), f(?, col2) from t group by f(?, col2)") I get an error from the DBMS complaining that f(?, col2) is not a GROUP BY exp...

JDBC prepareStatement doesn't work

I'm trying to use the prepareStatement function. The code is below. After it executes, it returns me a bunch of string 'vlicense' instead of the the values. When the code finishing the statement.setString(), the statement becomes "select 'vlicense' from Vehicle". However, it needs to be "select vlicense from Vehicle" without the quotatio...

Guaranteed cache hits when retrieving data

Problem setting Entities arrive for processing and are taken through a series of steps which operate on those entities and possibly on other, related, entities and generate some results; Some of the entities are required to be processed in real-time, without any database access; Currently the implementation simply looks up entities in ...

JDBC getConnection timeout issue

Hi, I have an application that uses connection pooling to get database connection from oracle9i release 9.2.0.4 database.Application is hosted in SJSAS 8.1 and the driver is ojdbc14.jar version 10.1.0.4. The problem I am having is datasource.getConnection() method is taking about 40 secs to throw an exception when the DB is down! This i...

Is statement.close() explicitly required in connection pooled environment?

I am using connection pooling in my application. My question is: Is it explicitly required to close statement before closing connection in case of connection pooled environment? In connection pooled environment connection is not getting closed, (but returns back to free connection pool). I had checked jdbc 4.0 functional specs. In poin...

What is a good strategy for caching prepared statements in Tomcat?

Hello, I am looking for a way to cache prepared statements in a servlet environment (specifically, Tomcat 5.5). This is meant to reduce the number of times that prepared statements are created, i.e. the number of times that connection.prepareStatement(sql) is called. My initial idea was to store PreparedStatement objects in the session...