jdbc

Hibernate is rounding my double ?

Hi, I've got a double which I'm trying to save to a postgres numeric column. The value I'm trying to save is 151.33160591125488, and I've verified that this is in fact the argument being received by Hibernates internals pre-insert. However the value in the database post insert is 151.331605911255, ie it's been rounded to 12dp. I know...

ClassNotFoundException com.mysql.jdbc.Driver

This question might have asked here number of times . After doing some google search for the above error and doing some update, I can't understand why I'm still getting that error. I've already put my driver-- mysql-connector-java-5.1.5-bin in the classpath: Java_Home\jre\lib\ Java_Home\jre\lib\ext\ Java_Home\lib and the code which I'...

Db2 connection problem with java.

I am having problem with DB2. I just installed the db2 as a db2admin and with a password. When i try to connect to database it is success full and while running any simple select query it give me following error:- DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.LOGIN, DRIVER=3.57.82 I have a database named onp and a tabl...

How to retrieve data which caused unique constraint violation (via Hibernate)?

Hi, Is there a way to find out which record caused such a violation in Hibernate? Normally you add objects to session and at the end you persist them. If such an error occurs it takes a while to track down which record has violated the constraint. Is there way to find out which record caused (either to "toString() in case of new obje...

Where to close statements in JDBC

I am using JDBC to retrieve data from a database. I understand that a Statement needs to be closed after it is used. However, I keep run into the same error telling me that no operation is allowed after the statement is closed. The structure of my code is like public void foo() { Statement; try { } catch{ } Statement.close(); } In my...

JDBC DatabaseMetaData.getColumns() returns duplicate columns

I'm busy on a piece of code to get alle the column names of a table from an Oracle database. The code I came up with looks like this: DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@<server>:1521:<sid>", <username>, <password>); DatabaseMetaData m...

JDBC, MySQL: getting bits into a BIT(M!=1) column

I'm new to using JDBC + MySQL. I have several 1/0 values which I want to stick into a database with a PreparedStatement. The destination column is a BIT(M!=1). I'm unclear on which of the setXXX methods to use. I can find the references for what data comes out as easily enough, but how it goes in is eluding me. The values effectivel...

How do I unlock an Oracle user's account from Java?

I'm trying to figure out why my application is unable to unlock a user's Oracle account successfully. Here's a snippet from my code: OracleDataSource ods = new oracle.jdbc.pool.OracleDataSource(); Properties props = new Properties(); props.put("user", "sys"); props.put("password", "sys"); props.put("internal_logon", "sysdba"); ods.set...

JDBC, MySQL: getting back row data from PreparedStatement executes.

I'm using the following setup: public MySQLProcessWriter(Connection con) throws SQLException { String returnNames[] = {"processId","length","vertices"}; addresser = con.prepareStatement("INSERT INTO addressbook (length, vertices, activity) VALUES (?, ?, ?)", returnNames); } processId corresponds to an auto-incrementing column in th...

Hibernate with Oracle JDBC issue

I have a select query which takes 10 min to complete as it runs thru 10M records. When I run thru TOAD or program using normal JDBC connection I get the results back, but while running a Job which uses Hibernate as ORM does not return any results. It just hangs up ...even after 45 min? Please help ...

jBPM + Spring transactions sharing and scope

Hi all. I've inherited an app using jBPM and Spring and am trying to figure out if it is configured the way it should be. First question: Does jBPM span a single JTA (JDBC and/or Hibernate) transaction across multiple actions in the same transition by default? If not, can it be configured to? So in the example below is there a way to sp...

Change Oracle JDBC Thin Client Identifier

When connecting to Oracle the JDBC driver identifies itself as "JDBC Thin Client" to Oracle (in v$session as the 'program'). There is also a 'ClientInfo' column in v$session that might be used for this, but it's always empty. We have a need to identify different applications connecting to Oracle (which are running on the same host, so t...

GSS-API MSSQL JDBC Driver

Has anyone found a JDBC Driver that supports GSS-API for MSSQL. I need to connect to a sql server using windows authentication. The fun part is it's the user logged into the application via JAAS not the user the application is running as. ...

Mysql syntax exception from jdbc

I'm trying to move the data from one table to another based on names which end with "@localhost", but while moving the data I'm getting an exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use n...

java 1.4 -sql server2000:is it safe to append text to String in java of size in gbs.

i am dynamically creating sql query for inserting multiple records in one hit.Suppose no of record to be inserted is 1000.in that case sql query will be generated as below in code String insertBatchSqlQuery=""; for(int currentRecordIndex=0;currentRecordIndex<totalNoOfRecords;currentRecordIndex++) { insertBatchSqlQuery+=getSQL...

How can I add a InterBase JDBC connection pool in GlassFish V3?

Using: InterBase 2007, latest interclient.jar (8.1.8), GlassFish v3 b68. I try to configure the connection pool in the web admin console page "Edit Connection Pool" with these settings: Resource Type: javax.sql.DataSource Datasource Classname: interbase.interclient.DataSource A 'ping' in the same screen returns this error message: ...

How do I track orphaned JDBC connections that are not closed?

We've found a bug in old code where connections aren't being closed. It's an easy fix, but I'm wondering how we go about proving that it's fixed. There is a choice of using a connection pool or not. For the pooling use it would be easy to add monitoring for the pool, but when connections pooling is not used, how do we track those unclos...

Can PostgreSQL be used with an on-disk database?

Currently, I have an application that uses Firebird in embedded mode to connect to a relatively simple database stored as a file on my hard drive. I want to switch to using PostgreSQL to do the same thing (Yes, I know it's overkill). I know that PostgreSQL cannot operate in embedded mode and that is fine - I can leave the server process ...

best practices for using sqlite for a database queue

I am using an sqlite database for a producer-consumer queue. One or more producers INSERT one row at a time with a new autoincremented primary key. There is one consumer (implemented in java, uses the sqlite-jdbc library) and I want it to read a batch of rows and delete them. It seems like I need transactions to do this but trying to u...

What's the easiest way to parse multi-line SQL statements in Java?

I'm pretty new to Java, but I'm looking for Java code that can take multi-line SQL statements, say something like this from a flat file: CREATE OR REPLACE TRIGGER REQ.TR_INPT_STAY_DETAI_SQ_BI BEFORE INSERT ON REQ.INPT_STAY_DETAIL FOR EACH ROW BEGIN SELECT REQ.SQ_INPT_DETAIL.nextval INTO :new.INPT_STAY_DETAIL_PID from DUAL; END; ...