jdbc

java ResultSet, using MAX sql function

Hello here is what I want, I connect to a DB and retrieve the biggest element of the UniqueId column, and assign it to an integer variable named maxID, here is my approach: int maxID = 0; Statement s2 = con.createStatement(); s2.execute("SELECT MAX(UniqueId) FROM MyTable"); ResultSet rs2 = s2.getResultSet(); // while ( rs2.next() )...

JRruby, Sybase JDBC and DBI - fetching column name with the AS clause issue

I have a ruby script which I run using the JRuby Interpreter. The script connects to a Sybase database using DBI and Sybase JDBC (jTDS3.jar and jconn3.jar) My problem is that I have a select query that alters the column names of table. For example: SELECT t.TRANSACTION as 'business_transaction', t.TRADE_CURRENCY as 'currency', t.CURREN...

How do I test with DBUnit with plain JDBC and HSQLDB without facing a NoSuchTableException?

I am trying to use DBUnit with plain JDBC and HSQLDB, and can't quite get it to work -- even though I've used DBUnit with Hibernate earlier with great success. Here's the code: import java.sql.PreparedStatement; import org.dbunit.IDatabaseTester; import org.dbunit.JdbcDatabaseTester; import org.dbunit.dataset.IDataSet; import org.dbuni...

Is java.sql.Connection thread safe?

To rephrase the question: should I avoid sharing instances of classes which implement java.sql.Connection between different threads? ...

Configuring jetty to work with JDBC datasource

Hi, i have an spring web application (on glassfish server) that use JDBC connection pool. It defined in XML file like this: <resources> <jdbc-connection-pool allow-non-component-callers="true" associate-with-thread="true" connection-creation-retry-attempts="2" connection-creation-retry-interval-in-seconds=...

Is it possible in Weblogic to create readonly JDBC datasource?

I am using Weblogic web server. Please let me know, how can i create a readonly JDBC datasource ,or should i handle this in my Java code ? ...

What causes a Spring 1.2 NullPointerException when creating prepared statement?

Using Spring 1.2.1 and oracle.jdbc.pool.OracleDataSource 10.2.0.3.0 I sometimes get a stack trace like below. I think it is caused by the connection pool being full. Does anyone know the cause for sure? Also do newer versions of spring or Oracle JDBC handle this better? java.lang.NullPointerException at org.springframework.jdbc.c...

What is the optimum number of sqls run in batch?

I am trying to load the data in Oracle server remotely. I am doing "executeBatch()" for every 50 sqls that are added in batch. (thru JDBC) What is the optimum number of sqls run in batch? Is it unlimited? ...

Java - Storing SQL statements in an external file

Java - Storing SQL statements in an external file I am looking for a Java library/framework/technique of storing SQL statements in an external file. The support team (including DBAs) should be able to alter (slightly) the statement to keep them in sync in case database schema changes or for tuning purposes. Here are the requirements: ...

Java/Oracle: executing a prepared statement fails on a second iteration of a loop (not all variables bound). Why?

I'm debugging a Java App, which connects to Oracle DB via a thin client. The code looks as follows: (i'm trying to simplify the use case here so pardon me if t does not actually comile) Connection conn = myEnv.getDbConnection(); CallableStatement call = conn.prepareCall( "{ ? = call SomePackage.SomeFunction (?)}"); call.regist...

MySQL - Connection using Singleton pattern or a ConnectionPool?

The topic has already been on the table in some previous questions. New elements come with new problems. I am seeking here for the best way to handle database connection(s), concerning aspects of : maintainability, performance, security and implementation. I must mention that i am not interested in abstractions like Hibernate, Spring, et...

How can I make JDBC drivers pluggable in an OSGi environment?

I have an OSGi project that, among others, contains one bundle with JPA annotated domain models and another which uses Eclipselink as persistency provider. The latter instantiates the EntityManager using a configuration parameter to determine the JDBC driver's class name. Now, the bundle with the models needs to be able to see the JDBC ...

Java with database storage.

I have to write a program that can take bookings, store them and then access them at a later time, the application has to be written in Java. Because of this i have been looking into various ways to use a database with Java. I have been looking into using the JDBC with the mySQL driver database and also looking into the javaDB. What wou...

How to define Spring datasource in controller ?

Is it possible to define a datasource connector in a Spring controller ? I'm working on a tool : synchronize a source table to a target table. I would define source and target in my controller (to synchronize different databases - in my view I can select different source and target databases). Actually, I define my datasource in file c...

jbdc connection with auto reconnect

i am using jdbc to connect to a database server the connection is over a wireless network and can be dodgy at times at the moment when the connection is lost they need to close and restart the application does anyone have some examples of code, where i could write some sort of wrapper to automatically reconnect and rerun the last query,...

Connecting to Progress database from Mac OSX

Does anyone know how to connect to a Progress 9.1E database from a Mac (or even from Linux)? I can connect successfully from Windows but the JDBC driver requires that the Progress install directory and it's bin directory are in the path. It seems to be one product that is firmly under Google's radar. OpenLink has an OSX driver but it i...

SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security; the connection has been closed. [CLIENT: 127.0.0.1]

i'm using JDBC to connect to SQL Server 2005 locally using integrated security. it's getting failed with the following error code Error: 17806, Severity: 20, State: 2. Logon SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security; the connection has been closed. [CLIENT: 127.0.0.1...

DDLUtils and autoincrement values

When trying to use DDLUtils it always seems to take over the id values for the columns that are set to autoincrement. How can I prevent this? For example, I have a Dogs table with a column called ownerID. The column ownerID is set to autoincrement. However my list of owners is not continuous, there are gaps (for example, ownerID's 2, 4,...

Mutlithread-safe JDBC Save or Update

We have an interesting problem: We have a JMS queue of job statuses, and two identical processes pulling from the queue to persist the statuses via JDBC. When a job status is pulled from the queue, the database is checked to see if there is already a row for the job. If so, the existing row is updated with new status. If not, a row is c...

ORM Technologies vs JDBC ?

Hi, My question is regarding ORM and JDBC technologies, on what criteria would you decide to go for an ORM technology as compared to JDBC and other way round ? Thanks. ...