jdbc

Oracle JDBC select with WHERE return 0

Hi, Similar question to: http://stackoverflow.com/questions/903488/strange-problem-with-jdbc-select-returns-null but people didn't ask for this. My code: public int myMethod(String day) throws SQLException{ String sql = "Select count(*) from MyTable WHERE someColumn = " + day; Connection connection = ConnFactory.get(); PreparedS...

jdbc + large postgresql query give out of memory

I'm trying to execute a postgresql query which returns a large result: connection.setAutoCommit(false); st = connection.createStatement( ResultSet.CONCUR_READ_ONLY, ResultSet.TYPE_FORWARD_ONLY ); st.setFetchSize(100); logMemory(); System.out.println("start query "); rs = st.executeQuery(queryString); System.out.println("done query "...

Closed Cursors - SQL Best Practice

Hi all, I work in a large, separated development team. The project I'm currently working on has an Oracle DB team that develops the stored procedures and other related components that our J2EE web-tier talks to. One thing that's arisen from development is the concept of a closed cursor when results aren't found. From my experience, c...

MySQL connections timing out/being abandoned under JRuby on Rails app on Jetty

Hi all, We're running a JRuby on Rails application on Jetty, and having reached the staging server prior to launch have suddenly hit a problem with our JDBC connections being abandoned. Here's a lovely stacktrace to illustrate: Last packet sent to the server was 12 ms ago. STACKTRACE: com.mysql.jdbc.CommunicationsException: Communica...

Understanding MySQL Connector/J's FLOSS exception

I have to create an application which transfers data from a local workstation into a remote MySQL database. Unfortunatly my boss doesn't want to pay for a commercial license, because it's not a critical application and we wouldn't make any money of it, but still he doesn't want to put the full source under GPL. (Please don't comment on...

JDBC Timestamp & Date GMT issues

I have a JDBC Date column, which if a i use getDate is get the 'date' part only 02 Oct 2009 but if i use getTimestamp i get the full 'date' 02 Oct 2009 13:56:78:890. This is excatly what i want. However the 'date' returned by getTimestamp 'ignores' the GMT values, suppose date; 02 Oct 2009 13:56:78:890, i end up getting 02 Oct 2009 15:5...

error :Data-Truncation while inserting in table

i am trying to insert the value in the table by passing the value in a function like this: public void insert(long r,String s_n,char sex,String sf_n,String sm_n,int c,char sec,long tel,long amount,String add,int age,String house) { try{ this.ps=this.con.prepareStatement("insert into s_table values(?,?,?,?,?,?,?,?,?,?,?,?)...

Are addBatch() and executeBatch() thread-safe?

Can i call executeBacth from a thread while another one keeps calling addBatch() on the same Statement ( or PreparedStatement ) object? Update: Does anyone have exprerience with this issue? 'cause i get incorrect results. Not all updates i added to the the batch is executed. ...

Reproduce com.mysql.jdbc.exceptions.jdbc4.CommunicationsException with a setup of Spring, hibernate and C3P0

I got this error from the production code: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was36940 seconds ago.The last packet sent successfully to the server was 36940 seconds ago, which is longer than the server configured value of 'wait_timeout'. You sho...

MySQL-JDBC Question: Can I use the column name as parameter?

Let's say I have a table with 3 columns: C1, C2, C3 I make a search based on the C1 column. Could I make something similar like this (this is not working - because this is not the way prepareStatement it's used:) ) String c;// the name of the column ... String sql = "select * from table where ? = ?"; pre = con.pre...

appfuse: should I configure jdbc credentials twice?

New to appfuse - I like the concept. I configured the username/password to the database in jdbc.properties. It didn't work. So I also configured my credentials in pom.xml Why is it so? Am I doing something wrong? ...

How do I setup my MySQL with Eclipse IDE?

I am using Eclipse EE IDE and I am using the MySql Connector/J driver. How do I set up a properties file with all the information(DB URL, DBusername,etc) Also I see that you need a DBname and DBurl for the properties file, How do I determine/create this name for the database. I have already looked at the mysql website for this and am sti...

Database Connection Always disconnect when Developing on same PC as DB

I am developing a JSP application and I used Oracle Express 10g as database. I notice when I try to develop in the same PC, I would only be able to make several page request and transition and I immediately get IO exceptions. But I download the same code in a different PC and connect to the said database PC. It does not kick me out immed...

appfuse: Embedded error: java.sql.SQLException: Field 'x' doesn't have a default value

appfuse: Embedded error: java.sql.SQLException: Field 'x' doesn't have a default value ...

How to use Java DB (named Derby) with hibernate

Hi guys i can connect Derby via Eclipse Database Development but i cannot connect Derby with same url with Eclipse Database Development's through Hibernate. Error :"Caused by: java.sql.SQLException: Another instance of Derby may have already booted the database " ...

Transaction state in JDBC

Is there a way to know if a transaction is in an "ongoing" state in JDBC? I found nothing in the Connection API. Thanks ...

How to connect SQLite with Java?

Hi, I am using one simple code to access the SQLite database from Java application . My code is import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class ConnectSQLite { public static void main(String[] args) { Connection connection = null;...

Oracle CLOB performance

I am running queries against an Oracle 10g with JDBC (using the latest drivers and UCP as DataSource) in order to retrieve CLOBs (avg. 20k characters). However the performance seems to be pretty bad: the batch retrieval of 100 LOBs takes 4s in average. The operation is also neither I/O nor CPU nor network bound judging from my observatio...

How to cancel a postgres query in java/JDBC

How do I cancel a long running postgres query via JDBC or Java? The usecase would be that an user starts a query on a postgres database via a front end, but then he decides otherwise and wants to abort/cancel the currently running query. ...

Autocommit false mode java

Hi All, I am not very sure about the auto commit mode of java JDBC, I am making a connection whose auto commit mode is set to false. After that I fire a select query on database, which works fine, I am under impression that commit has to be called only for insert, update, delete statements. Now do I need to commit the connection for Se...