jdbc

java.sql.SQLException: Io exception: Got minus one from a read call during JDBC connection with oracle

Hi I am new to java when I tried to connect oracle with my java sample code I got the above exception My Code is import java.sql.*; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; publ...

Can't update Oracle IOT table with jbdc updateRow method

Hello. I have Oracle 10gR2 database with IOT table within: create table countries ( id number primary key, name varchar2(30) not null enable ) organization index; I try to update table values with this Java (version 1.6) code: Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_U...

Which should I close first, the PreparedStatement or the Connection?

When using a PreparedStatement in JDBC, should I close the PreparedStatement first or the Connection first? I just saw a code sample in which the Connection is closed first, but it seems to me more logical to close the PreparedStatement first. Is there a standard, accepted way to do this? Does it matter? Does closing the Connection also...

JDBC Thin in Oracle 11g with java

Hi all, I am using oracle 11g. I write code to connect oracle database with java 1.6, but I can't connect to it. When configure the guide line to below: I have ojdbc6.jar,orai18n.jar, and class12.jar. I set Class_Path: %ORACLE_HOME%\jlib\orai18n.jar;r;%Oracle_home%\jdbc\ojdbc6.jar After that I run sample java code connect to oracle...

How is Oracle's JDBC query timeout implemented?

Hi, I was curious as to how the Oralce JDBC thin client implement query timeout. This can be set by calling java.sql.Statement's setQueryTimeout(int seconds) method. Is this implemented in the driver itself on the client side? Is a new thread spawned and joined? Or does the JDBC driver simply send a parameter to Oracle, and then it e...

Oracle JDBC connection caching + TAF failover?

Hello, Is it possible to use Oracle JDBC implicit connection caching in conjuction with Oracle TAF failover? Or is this available only to Fast Connection Failover? Thanks. ...

Difference between JDBC Driver type numbers

I am very new to Java, when i was going through the JDBC section, i noticed that JDBC has different Drivers like Type 1 Driver Type 2 Driver etc.. to Type 4 Why did they get the name like Type 1, Type 2 etc.., Is there any logic? ...

How can I get the SQL of a PreparedStatement?

I have a general Java method with the following method signature: private static ResultSet runSQLResultSet(String sql, Object... queryParams) It opens a connection, builds a PreparedStatement using the sql statement and the parameters in the queryParams variable length array, runs it, caches the ResultSet (in a CachedRowSetImpl), clos...

populating bean objects from the resultset

I am facing a problem regarding populating bean objects from the resultset. Description:Resultset contains the result of a stored procedure which is join of 3 tables B, BO, and BOV. I have 3 POJO's corresponding to tables. The relation between tables is: B can have 0 or more BO's, BO can have 0 or more BOV's. So totally in resultset I ...

How to Create a MySql Database using JDBC

Hi, Can we create a new MySQL database( not a table, I want a new database) from java code ? I have searched the internet and I get code only for connecting with existing mysql databases. Can i create a new database at run time using java code. please help ...

JDBC SQL Server Database Migrations

I'm working on a Java web application (Adobe Flex front-end, JPA/Hibernate/BlazeDS/Spring MVC backend) and will soon reach the point where I can no longer wipe the database and regenerate it. What's the best approach for handling changes to the DB schema? The production and test databases are SQL Server 2005, dev's use MySQL, and unit t...

Java - JDBC alternatives

Hello, this is just teorethical question. I use JDBC with my Java applications for using database (select, insert, update, delete or whatever). I make "manually" Java classes which will contain data from DB tables (attribute = db column). Than I make querys (ResultSet) and fill those classes with data. I am not sure, if this is the righ...

How to retrieve previous query using Swing JButton

I wrote a code sometime ago in which the object of ResultSet class res was able to retreive the next row of the database by using res.next(). But when res.previous() was used it was not working even though the method is defined in the resultset class. public void actionPerformed(ActionEvent e) { if (e.getSource() == next) { ...

How to add an Interbase connection pool to glassfish?

Hi, I am attempting to add an Interbase connection pool to GlassFish v3 to use EJB 3.1 in a project. The glassfish log appears to be connecting to my database properly, it spits out all my table names and indices. However, I get an error INFO: fetching database metadata SEVERE: could not complete schema update java.lang.NullPointerExc...

MySql timeouts - Should I set autoReconnect=true in Spring application?

After periods of inactivity on my website (Using Spring 2.5 and MySql), I get the following error: org.springframework.dao.RecoverableDataAccessException: The last packet sent successfully to the server was 52,847,830 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/...

SimpleJdbcCall ignoring JdbcTemplate fetch size

We are calling the pl/sql stored procedure through Spring SimpleJdbcCall, the fetchsize set on the JdbcTemplate is being ignored by SimpleJdbcCall. The rowmapper resultset fetch size is set to 10 even though we have set the jdbctemplate fetchsize to 200. Any idea why this happens and how to fix it? Have printed the fetchsize of resultse...

Parameters to tune when retrieving a lot of small BLOBs (2-10kb) from Oracle DB?

We have a table in which we store millions of small BLOBs (2-10kb). And we need to access a portion of this table at a time, iterating through it while retrieving all these BLOBs (this "portion" is usually in the order of 10**5 rows). We use oracle 11g R1. Right now I am thinking about tuning the OracleConnection.setDefaultRowPrefet...

Oracle Blobs - store size or calculate?

I am writing a generic Http resource hosting service and am storing larger objects as BLOBs in an Oracle database. I want to be able to set the 'Content-Length' header when returning a stored object, which means I need to know the size of the BLOB before I start writing it to the client (I know I could use chunked-encoding, and am in so...

What to keep alive and what to recreate in a simple embedded database?

In a desktop application with an embedded Derby database, what should I keep alive (as opposed to recreating each time when talking with the database) for the whole lifetime of the application? Connection and Statement, using the same statement throughout the lifetime of the program? Connection, recreating statement repeatedly? Neither...

Handling data maintenance in Object Databases like db4o

One thing I have continually found very confusing about using an object database like db4o is how you are supposed to handle complex migrations that would normally be handled by SQL/PL-SQL. For example imagine you had a table in a relational database called my_users. Originally you had a column named "full_name", now that your softwa...