jdbc

How to override TOMCAT Oracle ojdbc14 driver in the application?

The TOMCAT server is using an Oracle 9G ojdbc14 driver to its jndi connections in the /common/lib folder. My web application uses Maven + Spring and I'm getting the dataSource using Spring jndi features. I'm trying to bypass TOMCAT old ojdbc14 driver with a newer one (ojdbc14 10.2.0.4.0). I've tried putting the jars in the WEB-INF/lib ...

Update n number of records using JPA with Optimistic locking

I have a table with a column called "count" and I want to run a cron job that will trigger a statement that performs a SQL like this: update summaryTable set count=4; Note that there might be concurrent threads reading & changing the value for "count" when this cron job is triggered. The table has a version column to support Optimisti...

Drop all tables in sql server database using ant script.

Can anybody help me with this? I prefer if I don't have to explicitly list the table names. ...

JDBC CommunicationsException with MySQL Database

I'm having a little trouble with my MySQL- Connection- Pooling. This is the case: Different jobs are scheduled via Quartz. All jobs connect to different databases which works fine the whole day while the nightly scheduled jobs fail with a CommunicationsException... Quartz-Jobs: Job1 runs 0 0 6,10,14,18 * * ? Job2 runs 0 30 10,18 * * ?...

How do you access the value of an SQL count () query in a Java program

I want to get to the value I am finding using the COUNT command of SQL. Normally I enter the column name I want to access into the getInt() getString() method, what do I do in this case when there is no specific column name. I have used 'AS' in the same manner as is used to alias a table, I am not sure if this is going to work, I would ...

h2 in-memory tables, remote connection

I am having problems with creating an in memory table, using H2 database, and accessing it outside of the JVM it is created and running in. The documentation structures the url as jdbc:h2:tcp://<host>/mem:<databasename> I've tried many combinations, but simply cannot get the remote connection to work. Is this feature working, can anyon...

JDBC Pagination

Hi, I want to implement pagination using JDBC. The actual thing I want to know is "How can i get first 50 and then next 50 records from database for page 1 and 2 respectively" My Query is Select * from data [data table contains 20,000 rows] For page #1 I get 50 records and for page #2 I want to get next 50 records. How can I implement...

When accessing ResultSets in JDBC, is there an elegant way to distinguish between nulls and actual zero values?

When using JDBC and accessing primitive types via a result set, is there a more elegant way to deal with the null/0 than the following: int myInt = rs.getInt(columnNumber) if(rs.wasNull())? { // Treat as null } else { // Treat as 0 } I personally cringe whenever I see this sort of code. I fail to see why ResultSet was not defined to...

Can I get a table name from a join select resultset metadata

Below is my code trying to retrieve table name form Resultset ResultSet rs = stmt.executeQuery("select * from product"); ResultSetMetaData meta = rs.getMetaData(); int count = meta.getColumnCount(); for (int i=0; i<count; i++) { System.out.println(meta.getTableName(i)); } But it returns empty, no mention it is a join select results...

java.sql.SQLException: OALL8 is in an inconsistent state On weblogic 9

Hello, We are getting this error "java.sql.SQLException: OALL8 is in an inconsistent state " when executing our web app on weblogic 9. The jdk used is 1.5 and database is Oracle10.2g We have switched out oracle drivers ojdbc14.jar with ojdbc5.jar. We have also added orai18n.jar. We have ensured that this change of jar occurs with the web...

How to get all table names from a database ?

Hi, I'd like to retrieve all table names from a database schema, and, if possible, get all table starting with a specified prefix. I tried using JDBC's connection.getMetaData().getTables() but it didn't work at all. Connection jdbcConnection = DriverManager.getConnection("", "", ""); DatabaseMetaData dmd = jdbcConnection.getMetaData(...

Printing SQL Query In PreparedStatement in oracle.jdbc.driver.OraclePreparedStatement

I need to see the query being sent to Oracle from a Java program. In the PostgreSQL JDBC driver, toString() does the job, but the same does not apply to prepared statements from Oracle JDBC implementation. Any ideas how to achieve that? ...

Can I and should I use Eclipselink for non OR database interactions?

We are using Eclipselink for ORM, but we have a need for some more lightweight database interactions that are more equivalent to JDBC. My question is whether Eclipselink supports such an idiom and whether there are any advantages of it to straight JDBC. I can see one advantage being consistency and being able to use the existing connecti...

IS ResultSet thread safe

Is ResultSet Thread safe? My question arises because in my program i have used different statement for each query i have declared a ResultSet as an local variable but it gives me a error of Operation not allowed after ResultSet is closed. But my statements are working as i'm using the statements in insert and delete query.I have commen...

java jdbc connection to mysql problem

Hi, I am trying to connect to mysql from java web application in eclipse. Connection con = null; try { //DriverManager.registerDriver(new com.mysql.jdbc.Driver()); Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost/db_name","root" ,""); if(!con.isClosed()) System...

java connectivity with mysql

How to set up type 1 connectivity with MySql datasource and java application in windows xp service pack 3 environment? ...

PACKAGE.TABLENAME%ROWTYPE in JDBC

Hello, We have a stored proc where it returns a record which is of type PACKAGE.TABLENAME%ROWTYPE. we are finding it difficult to map in JDBC? Does anyone shed some light on this? ...

Setting session timezone with spring jdbc oracle

Hello I have a spring/jdbc/oracle 10g application. The Oracle server database timezone is set to GMT + 2 JVM timezone is GMT + 2 (even though it doesn't matter in my case). I have a stored procedure that performs some date operations. The problem is that session timezone is different(GMT) than database timezone even though I do not set...

How can I get the name of all tables in a JavaDB database?

How can i programmatically get the names of all tables in a JavaDB database? Is there any specific SQL-statement over JDBC I can use for this or any built in function in JDBC? I will use it for exporting the tables to XML, and would like to do it this way so I don't miss any tables from the database when exporting. ...

Is it safe to use connection.createStatement().executeQuery(String query);?

Is it safe to do connection.createStatement().executeQuery(String query);, or should each java.sql.Statement object be created and closed by "hand" on every use, even if the connection is closed in a finally block? If multiple queries are executed in one method by one connection it would use much less code if instantiating and closing e...