jdbc

Eclipse and Classpath.

I swear I'm going insane. JDeveloper runs my project with not a single complaint. If I do "java -cp /usr/share/java/mysql.jar:. MAIN.java", it works like a charm. But Eclipse says "[censored] you" and ignores my classpath settings. I open the Run > Run... menu, and add the mysql jar in the classpath tab, but time and time again, I ke...

What is the best way/template to set up connection mysql and jdbc?

What is the best way to set up connection with mysql's jdbc? And execute simple statement. How to do that? Thank you. ...

mysql driver jar not being recognized

Hi all, I have an token class file in an jar file. The token class files is the class that uses jdbc to retrieve data from the database. However when I call the jar file it does not seem to recoginize the external mysql driver jar file. The error is pointed to this line Class.forName(driver);. I have referenced the mysql driver in...

Reading a CSV file into Java as a DB table

I've found numerous posts about reading CSV with Java and the APIs they were pointing at all had a line-oriented approach when it came to reading a CSV file. Something like "while you get a line, get the values of every column". I'd appreciate a higher-level API, like in Perl where DBI allows you to use SQL on CSV like if it where a DB ...

Hibernate vs. JDBC

I am working on a project that previously used Hibernate. Honestly, it seems like Hibernate complicates it more than JDBC would have. Also, it seems that a lot of the power of the relational database is lost. What are the advantages of using Hibernate over JDBC? ...

Large ResultSet on postgresql query

I'm running a query against a table in a postgresql database. The database is on a remote machine. The table has around 30 sub-tables using postgresql partitioning capability. The query will return a large result set, something around 1.8 million rows. In my code I use spring jdbc support, method JdbcTemplate.query, but my RowCallbackH...

Question on Prepared Statement in Java

We have a Prepared Statement in Java and we hear that it is different from Statement in the Way that this prepared statement need not be compiled every time it is used. My question is where is this Compiled Statement stored ? In the Client code that uses it or is it stored by the Database ? Why would a DB Store a Compiled statement and...

Comparison of JDBC Connection pools

Does anyone have any information comparing performance characteristics of different ConnectionPool implementations? Background: I have an application that runs db updates in background threads to a mysql instance on the same box. Using the Datasource com.mchange.v2.c3p0.ComboPooledDataSource would give us occasional SocketExceptions: ...

What is a Connection in JDBC ?

What is a Connection Object in JDBC ? How is this Connection maintained(I mean is it a Network connection) ? Are they TCP/IP Connections ? Why is it a costly operation to create a Connection every time ? Why do these connections become stale after sometime and I need to refresh the Pool ? Why can't I use one connection to execute multipl...

SQLServer deadlock

Hi, I have a java application which is doing multiple concurrent CRUD operations on a database. I'm adding support for SQLServer but am having problems with deadlocking during concurrent deletes. After some investigation it appeared that the problem may be due to lock escalation on a particular table. In an attempt to fix it, I decide...

How can I set the application information on a session using the Oracle thin JDBC driver?

I'd like to change the application information that is shown when inspecting Oracle 10g sessions using the Oracle Enterprise Manager application: Application Information Program 'my program' Module 'something' Command UNKNOWN I'm using the JDBC thin driver to connect, and I have to admit I'd rather not use the OC...

What is the best way to 'ping' a database via JDBC?

I'm trying to determine the best way to ping a database via JDBC. By 'best' I mean fast and low overhead. For example, I've considered executing this: "SELECT 1 FROM DUAL" but I believe the DUAL table is Oracle-specific, and I need something more generic. Note that Connection has an isClosed() method, but the javadoc states that this...

Temporary in-memory database in SQLite

Is it possible somehow to create in-memory database in SQLite and then destroy it just by some query? I need to do this for unit testing my db layer. So far I've only worked by creating normal SQLite db file and delete if after all tests, but doing it all in memory would be much better. So is it possible to instanciate database only i...

Auto generate key on JDBC insert in SQL Server

Is there a general, cross RDMS, way I can have a key auto generated on a JDBC insert? For example if I have a table with a primary key, id, and an int value: create table test ( id int not null, myNum int null ) and do an insert PreparedStatement statement = connection.prepareStatement("insert into test(myNum) values(?)", Statem...

Java ResultSet getString weirdness?!

This one has me stumped. I've got a java.sql.ResultSet and I'm pulling string values out of it like so: address.setAddressLine1(rs.getString("AddressLine1")); address.setAddressLine2(rs.getString("AddressLine2")); When I debug and inspect rs.getString("AddressLine1"), the debugger says I've got a 30 character string: "ATTN: ACCOUNTS ...

Is there any JDBC Type 4 driver for DB2 v6?

Does DB2 UDB v6 supports JDBC Type 4 drivers? Where can I get that JDBC Type 4 driver? ...

Strange Exception on getGeneratedKeys() with JDBC for MySQL 5.1

Hello, I'm using JDBC to insert a row into a MYSQL database. I build a parameterized command, execute it and attempt to retrieve the auto generated keys as follows: String sql = "INSERT IGNORE INTO `users` (`email`, `pass-hash`) VALUES (?, ?)"; Connection conn = SQLAccess.getConnection(); PreparedStatement ps = conn.prepareStatement(...

JDBC connection to Oracle Clustered

Hello, I would like to connect to a clustered Oracle database described by this TNS: MYDB= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host1)(PORT = 41521)) (ADDRESS = (PROTOCOL = TCP)(HOST = host2)(PORT = 41521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME= PDSALPO) ...

What can cause the SQL Server JDBC error 'The value is not set for the parameter number 0' for an output parameter access?

I have some Java code that accesses SQL Server 2005 which looks something like this: CallableStatement cstmt = ...; ... // Set input parameters cstmt.registerOutParameter(11, Types.INTEGER); cstmt.execute(); int out = cstmt.getInt(11); And the following exception is thrown from the last line: com.microsoft.sqlserver.jdbc.SQLServerExc...

copying oracle to sqlserver 2005 jdbc

Is there any way of copying a database from oracle to sqlserver 2005? Thanks ...