jdbc

what is the harm of using executeQuery instead of executeUpdate for deleting rows

In my code I am using String query= "delete all from myTable"; stmt.executeQuery(query); Ideally for DML executeUpdate should be used instead. However, executeQuery too works well. So, was curious to know what could be the harm of using executeQuery instead of executeUpdate? ...

P6spy doesn't spy on hsql jdbc driver

When trying to spy on the jdbc connection to a hsqldb database it doesn't work. It looks like the org.hsqldb.jdbcDriver is not deregistered. ...

Help in getting a database management system running.

http://projectabstracts.com/406/java-based-online-shopping.html This project is about "Online Shopping". It uses Java as front-end implementing applets, servlets and JDBC as the connecting link to the back-end which is implemented using SQL. The problem is that I'm a newbie in all this stuff and I don't understand how to get this projec...

What characters will PreparedStatement escape?

I noticed that when I use a PreparedStatement it doesn't seem to escape certain wild-card characters like '%' or '_'. I know these can be escaped in MySql using a backslash. This made me wonder, what characters will a PreparedStatement escape? ...

How to correct drivermanager.getconnection exception

I want know about how to correct driver connection exception. I got that exception as drivermanager.getconnection exception. Does any one know please answer me. I use ODBC Bridge connection and MS ACCESS Database. Class.forName("sun.jdbc.odbc.JdbcOdbc"); Connection con = DriverManager.getConnection("jdbc:odbc:mydb", "", ""); excepti...

How to check that a ResultSet contains a specifically named field?

Having rs, an instance of java.sql.ResultSet, how to check that it contains a column named "theColumn"? ...

No server-side prepared statements using MySQL Connector/J

From what I understand, MySQL 5.1 supports server-side prepared statements. Therefore the following code should prepare the statement once, and execute it 10 times: Connection conn = ds.getConnection(); PreparedStatement stmt = conn.prepareStatement("SELECT COUNT(*) FROM users WHERE user_id=?"); for (int i=0; i<10; i++) ...

How should I use UUID with JavaDB/Derby and JDBC?

I currently use INT as type for primary key in JavaDB (Apache Derby), but since I'm implementing an distributed system I would like to change the type to java.util.UUID. A few questions about this: What datatype in JavaDB/Derby should I use for UUID? I have seen CHAR(16) FOR BIT DATA been mentioned but I don't know much about it. Is VA...

Connecting to JDBC-ODBC using File DSN

When connecting to a DB using JDBC-ODBC Bridge (sun.jdbc.odbc.JdbcOdbcDriver), how should the URL be formatted if a File DSN is to be used? I'm using SquirreLSQL to connect with a File DSN stored on a network drive. It seems that JDBC-ODBC can't recognize the file. Or my URL could be wrong. It works when I use a system DSN. I've tried a...

java.lang.UnsatisfiedLinkError while loading DB2 JDBC driver

I try to use jboss-seam with a db2 database, the following error occurs com.ibm.db2.jcc.a.SqlException: [jcc][10389][12245][3.52.95] while loading the native library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path an error occurred ERRORCODE=-4472, SQLSTATE=null I tried setting -Djava.library.path=/opt...

SQLite database file created from JDBC?

Hi everybody, I have created a SQLite database from Java. Now I want to know where it is stored physically on disk, so that I can use push that file on to Android. ...

Accessing infobright from Java

Hello guys! Would someone advise me technology for accessing Infobright from java, or some technics... things of that nature.. as far as I understand I should use plain jdbc connection and execute queries... not making use of high level thing like hibernate... Am I right? Thanks in advance! ...

Incorrect Use of JDBC Connection Pool

I am running a Spring MVC application, backed by a MySQL database which I am accessing using JDBC. I have been using the same code for a while, and have never really taken a look as to whether or not I was using it correctly(using connection pools properly,etc). I am aware that there is the JDBCTemplate out there, and I have considered ...

Spring JdbcTemplate ConnectionPooling Configuration

I am working on a Spring MVC application in which I have recently been convinced to revamp my database code. Before I was using very traditional JDBC code that I have been told was very "old school" because of the boilerplate code. I have been making the transition to using JdbcTemplate with Spring. I have configured a bean like shown b...

Character encoding problem using ScrollableResults and MySql

I'm doing private void doSomething(ScrollableResults scrollableResults) { while(scrollableResults.next()) { Object[] result = scrollableResults.get(); String columnValue = (String) result[0]; } } I tried this in two computers It works fine. It is a Windows 7. System.getProperty("file.encoding") returns Cp1252. ...

Should JDBC connection handles be per-app, per-thread, or per-query?

Let's say we've got a web application or web service on an application server supporting JDBC connection pooling. Should I be grabbing a new Connection on a per-thread or per-query basis? Thanks! ...

How to measure time to execute a query when using SimpleJdbcTemplate

The only solution I can come up with is to write a decorator class that decorates each and every method of SimpleJdbcTemplate, and logs the time taken. Do you have any thing better?? ...

Type 5 JDBC Driver

Is anybody has tried JDBC type 5 driver. Is it faster than JDBC 4 driver? ...

JDBC insert statement is not working

I am trying to insert new record, using jdbc. Everything look like ok, I don't have any exception, but new record isn't inserted into the table. Select statement works right. public Connection getConnection(){ Connection conn=null; try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { ...

JDBC Video Tutorials

I am trying to learn how to connect my Java code to an MySQL database. I am looking for some good video tutorials (if none exists, I'd be interested in non-video tutorials). Thanks in advance, this will really help me! ...