jdbc

JDBC transaction dead-lock: solution required?

My friend has described a scenario and challenged me to find solution. He is using Oracle database and JDBC connection with read committed as transaction isolation level. In one of the transactions, he updates a record, executes a select statement and commits the transaction. When everything happens within a single thread, things are fin...

JDBC Realm: GlassFish v2.1 = OK; GlassFish v3 = fail with invaliduserreason

In my J2EE 5 application I have a JDBC Realm based security with Form method. Encrypt method is MD5 as default. The database is PostgreSQL 8.4 installed locally (or 8.3 available via lan). My app used to work finely on GlassFish v2.1 server with PostgreSQL 8.3, but now I need to deploy it on GlassFish v3. I am absolutely sure I have ...

How can I add a password to this JDBC:ODBC connection string that is trying to connect to an MS Access database.

This is the connection string that is currently working on a non-password protected MS Access database. this code snippet is from our properity file: db.url = jdbc:odbc:Driver\={Microsoft Access Driver (*.mdb)};Dbq\=C:\Inventory.mdb;DriverID\=22;READONLY\=true How do I add a password to this connection string for a MS Access DB pro...

How to log all sql going through JBoss datasource with log4j

I've looked at log4jdbc (which does not support datasources), p6spy which seems to be what I am looking for but it has not been updated since 2003 which makes me nervous and lists only JBoss 3.x (we use JBoss 5), and JAMon which seems heavyweight for what I am trying to accomplish (a simple log of all SQL statements running through a JBo...

JBoss JDBC warning - "Unable to fill pool"

We're getting this random warning from JBoss.. any idea why? It happens at random times when there are no active threads. Everything works when any processing resumes. 13:49:31,764 WARN [JBossManagedConnectionPool] [ ] Unable to fill pool org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (ja...

JDBC query to Oracle

Hi, We are planning to migrate our DB to Oracle.We need to manually check each of the embedded SQL is working in Oracle as few may follow different SQL rules.Now my need is very simple. I need to browse through a file which may contain queries like this. String sql = "select * from test where name="+test+"and age="+age; There are near...

selectively update prepared statement

for an prepared statement update table t set a = ? ,b = ? where i = ? column a to stay column a ie. a=a and only need to setInt for b and visa versa, without needing another statement. Is there a concise way of doing this? ...

ResultSet.getTimestamp("date") vs ResultSet.getTimestamp("date", Calendar.getInstance(tz))

java.util.Date, java.util.Timetamp were seems to be causing great confusion for many. Within StackOverflow there are so many questions, Unfortunately my question is bit twisted. There are 2 JDBC api. How they should perform? Was there any consistencies among RDBMS’es? ResultSet.getTimestamp("dateColumn") ResultSet.getTimestamp("dateCo...

how to handle result set data

Hello All I am getting lot of records in my Result Set. My concerns are : How Result Set handle these records internally? and How a programmer can handle those records in batches So that memory problem would not occur.? waiting for your answers .. Many Thanks ...

Speed up multiple JDBC SQL querys?

I'm working on a shortest path a* algorithm in java with a mysql db. I'm executing the following SQL Query approx 300 times in the program to find route connections from a database of 10,000 bus connections. It takes approx 6-7 seconds to execute the query 300 times. Any suggestions on how I can speed this up or any ideas on a different ...

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I am trying to connect to mysql database using java on windows7. Inspite of adding the complete url of jdbcdriver jar file in CLASSPATH, java.lang.ClassNotFoundException: com.mysql.jdbc.Driver is thrown. Could anyone tell me what i am missing here?? it works if i add the jar file in project library but i want to do it by CLASSPATH itself...

How to check if resultset has only one row or more?

How to check if resultset has only one row or more? ...

Weblogic 10.3, JDBC, Oracle, SQL - Table or View does not exist

Hi, I've got a really odd issue that I've not had any success googling for. It started happening with no changes to the DB, connection settings, code etc. Problem is, when accessing a servlet, one of the EJB's is doing a direct SQL call, very simple "select \n" + " value, \n" + " other_value \n" + " from \n" + " some_table \n" + " ...

Why do I keep on getting an exception-illegal operation on ResultSet?

Why do I keep on getting an exception-illegal operation on ResultSet? Here is the code: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * SearchParts.java * * Created on 08-Mar-2010, 12:14:31 */ package garits; import java.sql.*; import javax.swing.*; /** * * @author Deniz...

Can I build a resulset from a file in Java?

I don't have much experience working with resultsets, but as ResultSet is an interface, I guess I could implement it to work with a file as a backend. Is this nonsense? Is there any solution already given for my problem? ...

Tomcat fails to start because of jdbc driver loading

Here's the relevant portion of the tomcat startup log: SEVERE: Context [/f360] startup failed due to previous errors Apr 8, 2010 6:45:56 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: A web application registered the JBDC driver [org.apache.derby.jdbc.ClientDriver] but failed to unregister it when the web ap...

Using sql column names in hibernate createSQlquery result

Hi all, i have a couple of sql views with composite primary keys that i want to query, and since Hibernate makes it a pain to work with composite keyes, im using createSQLQuery. The problem is that this method can only return a List, and i need to refer to the colums by their index. Any chance i could do like jdbc and refer to the col...

Specifying a variable name in QUERY WHERE clause in JDBC

Could someone please give me a link on how to create a query in JDBC that gets a variable name in the WHERE statement, or write an example, to be more specific, my code looks something like this: private String getLastModified(String url) { String lastModified = null; ResultSet resultSet; String query = "select LastModif...

How to get the number of columns from a JDBC Resultset?

I am using CsvJdbc (it is a JDBC-driver for csv-files) to access a csv-file. I don't know how many columns the csv-file contains. How can I get the number of columns? Is there any JDBC-function for this? I can not find any methods for this in java.sql.Resultset. For acessing the file, I use code similar to the example on the CsvJdbc web...

How do I get the median/mode/range of a column in SQL using Java?

I have to get the median, mode and range of test scores from one column in a table but I am unsure how to go about doing that. When you connect to the database using java, you are normally returned a ResultSet that you can make a table or something out of but how do you get particular numbers or digits? Is there an SQL command to get the...