jdbc

JDBC MySQL; is supplying the DB name & username/password enough?

Hi, When setting up a JDBC connection in a J2EE application, do you need to specify the schema name in addition to the database name? I have followed this tutorial and have setup a database, and username/password, but I'm coming up against this error when I startup my application. Is it possible that DBUnit is trying to insert the data...

spring jdbc RowCallbackHandler nightmare

I'm having trouble retrieving data from my database using Spring Jdbc. Here's my issue: I have a getData() method on my DAO which is supposed to return ONE row from the result of some select statement. When invoked again, the getData() method should return the second row in a FIFO-like manner. I'm aiming for having only one result in me...

Java + MySQL integrity violation handling

Hello, I write Java program using JDBC (mysql database). When I violate mysql integrity (f.e. I try to insert same primary key value) I catch SQL exception. Should I write it in way it may never happen (f.e. at first boolean function checking whether primary key value isn't already in DB and then calling insert), or is it okay to handle ...

How to set fetch size in Hibernate against an Oracle database?

When programming directly in JDBC against an Oracle database you can call stmt.setFetchSize(fetchSize) on the statement to determine the max number of records to fetch in one round trip from the small default value. I'd like to do this from withing Hibernate 3.2. Can someone tell me where this would be set? ...

JDBC TableModel for a JTable in Java?

I want to display a database table as a JTable. I have never used JTable before so I googled JTable and TableModel. With that googling, I am able to write my own custom TableModel which show data stored in Object[][] data; Now, I want to show my database table data into JTable. I searched that also and have got an idea of that but s...

trying to get a query to use the LIKE function with a variable in JSP

I have a query that is being used to pull usernames and info about the user. In Access I had the LIKE function so that the user didn't have to type in a specific name. I am now transferring it over to JSP. Here is the line in the query that I am having troubles with in JSP: WHERE ObjectName Like '" + "%"+ VariableName + "%" +"'; The q...

SQL Server JDBC Exception

When using ANT to build my Java application I keep getting this error. I have tried multiple times to use SQLJDBC.JAR and SQLJDBC4.JAR but continually receive this error message. I am completely stumpped why this error is received even after upgrading to sqljdbc4.jar. [javadoc] java.lang.UnsupportedOperationException: Java Runtime...

How can I get the column name of the primary key of a Database Table from the ResultSet or ResultSetMetaData object in JAVA?

I am writing a Java Application. I have got a ResultSet. Now I want to find out the coloumn name of the primary key of the table. Is it possible to get that coloumn name through ResultSet object or ResultSetMetaData Object or any other way. I didn't find any way to find this. ...

Performance differences between jconn2 and jconn3

Hi, I have tested jconn2 and jconn3 on same application which is connected to sybase ase15.03 server . But I encountered the really big performance differences between these two api. For example I have run a simple select query on a big table (which contains 7051328 rows 20 cols). JCONN2 returns the resultset in 5.3sec but jconn3 retur...

ant sql task throws "no ResultSet available" with org.sqlite.JDBC driver

I'm trying to use org.sqlite.JDBC to create and update a sqlite database in ant. The sqlitejdbc-v056.jar comes from http://www.zentus.com/sqlitejdbc/ and is the latest version (056) This is my build.xml: <?xml version="1.0" encoding="utf-8"?> <project name="My Project" default="mytarget" basedir="."> <path id="antclasspath"> ...

iBatis 3 - JNDI configuration example

The iBatis framework has been significantly tweaked between versions 2 & 3, so much that even the config file (now often referred to as MapperConfig.xml) is different. That being said, there are lots of examples online on how to create a JDBC connection pool with iBatis, but I couldn't find one example on how to do it with JNDI. There ...

How to access a UniqueIdentifer column from Java's JDBC-ODBC bridge

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 Resulet...

JDBC converting dates to UTC

Hi all, I have some code inserting a timestamp in a Postgres table. Here is the definition of the field where the timestamp is inserted: datelast timestamp without time zone I use this Java code to update data in the field: PreparedStatement sqlStatement = connection.prepareStatement( "UPDATE datetest SET datelast = ? WHERE ...

JDBC Batch Insert OutOfMemoryError

Hi I have written a method insert() in which I am trying to use JDBC Batch for inserting half a million records into a MySQL database: public void insert(int nameListId, String[] names) { String sql = "INSERT INTO name_list_subscribers (name_list_id, name, date_added)"+ " VALUES (?, ?, NOW())"; Conn...

Joining multiple result set

I am trying to develop a Java application which merges data from multiple data source basically RDBMS. The scenario is some thing like this. I have creates a connection to two data sources, lets say a MSSQL database and other Oracle. Also on each connection a user can create a DataObject( a Java object) which contains a SQL query and a ...

Are there any good CachedRowSet implementations other than the proprietary Sun one?

I am investigating using javax.sql.rowset.CachedRowSet in part of my application, however I can only find information on using the proprietary sun implementation com.sun.rowset.CachedRowSetImpl or Oracle specific implementations. The sun implementation is unsupported and subject to change. Using this could cause also us problems if we w...

SQL queries running slowly or stuck after DBCC DBReindex or Alter Index

All, SQL 2005 sp3, database is about 70gb in size. Once in a while when I reindex all of my indexes in all of my tables, the front end seems to freeze up or run very slowly. These are queries coming from the front end, not stored procedures in sql server. The front end is using JTDS JDBC connection to access the SQL Server. If we stop a...

New ldap records not appearing when using jdbc

I have an LDAP server setup (OpenLdap). It uses MySQL as a backend - and everything works wonderfully. When I add a new record to the table, I can see the new record in an LDAP browser immediately. However, when I insert a record into the database using JDBC (via a hello world-ish java app), the record does not appear in my LDAP browser...

When to shut down message processing in case of queue / database failure?

This is more of a best practice question for the common case of an application receiving messages, persisting them to a database, and possibly sending messages as a result. Assume transactionality sorts out atomic commit; what is a good policy on when to shut the application down altogether? If the database fails, the application could...

Java: JDBC ResultSet not populated with all query results

I'm working on getting our system's java beans to be able to use the SQL IN clause when running queries down through the database, but am running into a perplexing problem. I am build the SQL query for the PreparedStatement in the following generic pattern: select [column names] from [table name] where [a column name] IN (?, ? , ?, .....