jdbc

Do prepared statements slow down program conspicuously?

I am writing a software that requires me to prepare statements and set the values, execute the query and get results within a loop. This loop might have over 7,000 cycles. If I use simple statements rather than prepared statements, will the execution speed change greatly? Here is the pseudo code Prepare Statements Get a list from some...

Can I ignore or suppress warnings in JDBC for MySQL?

I have an INSERT INTO ... ON DUPLICATE KEY UPDATE ... statement that executes fine (but with warnings) in the mysql> prompt: mysql> INSERT INTO ... ON DUPLICATE KEY UPDATE ... ; Query OK, 2 rows affected, 2 warnings (0.00 sec) Warning (Code 1364): Field 'x' doesn't have a default value However, when I try to execute the same statement...

Problem reading special characters from teradata - JDBC

I use teradata and the below query outputs "Altlüd" when run using a teradata client. select name as name from MYTABLE where selector=? Whereas, I get "Altl?d" as the output when I try to execute the query using a java client(jdbc with teradata drivers). I am using "UTF-8" charset and I have also tried Latin charset with no luck. I ...

What's the problem in the next sequence of Java/SQL code?

Hi! I made an update to a table in access via Java code, and it doesn't work. But, when I print to the console the result of executeUpdate(), it shows me 1, but in the database, no change. Can you tell me where's the problem, please? System.out.println("here"); PreparedStatement st = conn.prepareStatement( "UPDATE StocProduseCuFact...

Upgrading to Oracle JDBC thin driver results in SQLException: Unexpected exception while enlisting XAConnection

In Upgrading to Oracle JDBC thin driver results in SQLException: Unexpected exception while enlisting XAConnection (WebLogic Server 10.0, oracle version ) we are getting the error listed below. We did follow Oracle's advice to change the global timeout in weblogic, i.e. For the JDBC Connection Pools set the XASetTransactionTimeout to ...

How to obtain sale by date in java?

I am using ms access DB. I need to obtain sale by date. Here is my table specification: BILL_NO DATE SALE 1 8/30/2010 1000 2 8/30/2010 2000 3 8/31/2010 3000 4 8/31/2010 2000 If i want the sale for 8/31/2010 it should return 5000. I have inserted Date values using java.sql.Date object in DB. ...

tomcat 6.0 with JDBC throws ClassNotFoundException com.mysql.jdbc.Connection

I've successfully connected to MySQL database through Eclipse without getting tomcat involved, so at lease it's some good progress. But when I try from my web page (Tomcat 6.0), it throws an error. I followed the tutorials, read documentations and looked countless forums but cannot figure out for 2 days now. Let's look at the step one b...

Problem in Decimal Value

private static DecimalFormat decimalFormat = new DecimalFormat("0.0000000000"); public static void main(String[] args) { String str ="73.71" ; BigDecimal decimal= new BigDecimal(str); System.out.println("Tesing1 " + decimal.floatValue()/10000); System.out.println("Tesing2 " + decimal.f...

Access to jdbc/ jndi properties associated with the Datasource in BIRT

Is there a way to access jdbc/ jndi resource properties associated with a Datasource in BIRT? I would like to access the properties (esp. driverClass) to modify the query associated with the datasets to address database engine specific variations. TIA ...

adding new users to the database upon registering on a website using JSP and JDBC

I am now working on a web application project for the first time, the application includes registering and adding users to the database, now i wrote a java class called DatabaseManager that implements all database operations, and wrote the JSP page responsible for adding new users, if the registration is successful I need to add the user...

Java MySQL Update Query

I am getting the error "cannot issue data". Here is the SSCCE //package mysqltest; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.applet.Applet; import java.awt.TextArea.*; import java.sql.*; import java.util.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.*; import java.net.*; import java.ap...

Java - JDBC connection

I am getting this error: FOR REAL Looking for database... com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at sun.reflect.NativeConstructorAccessorImpl.newInstan...

Can I ask JDBCTemplate to expand a list parameter for use in an in() clause?

Can I do something like this: select * from mytable m where m.group_id in (?) ... and pass in a list or array of arguments to be expanded in to my parameter, ie: select * from mytable m where m.group_id in (1,2,3,4) Specifically, I'm using Spring and the JdbcTemplate/SimpleJdbcTemplate classes. ...

Java - Communications Link Failure

I just talked to my host that I have my web page at and they say they allow JDBC connections. Anyway, the page you can view this at is http://mystikrpg.com/mysqltest/mysqltry.html Here is my error: **** Looking for database... com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent su...

JDBC reconnect problems with Teradata driver using Spring and Apache DataSource

I'm using the Apache BasicDataSource for both commons DBCP and connection pool: org.apache.commons.dbcp.BasicDataSource and managing it through Spring: org.springframework.jdbc.datasource.DataSourceTransactionManager While using this combination with the Teradata JDBC driver if my database goes down or there is a network glitch I r...

JDBC: default holdability of a ResultSet

Hi, is there a defined default for the holdability of ResultSet, if Connection.setHoldability() is never invoked or a holdability is never specified during the creation of a statement? I could not find anything in the JDBC api docs - so is it implementation specific? Thank you. ...

How can I get a custom CallableStatement object out of a prepareCall method.

I want to create a subclass that extends the CallableStatement object. I want to do this so I can override the execute and executeQuery methods to track some metrics on each SP call. Currently I have code that looks like this: Connection db = poolingDataSource.getConnection(); CallableStatement cstmt = db.prepareCall("{call pSampleSto...

Do a DB2 insert with a select and parameters

I want to do something like this: INSERT INTO TABLEA ( COLUMN1, COLUMN2, COLUMN 3 ) SELECT FOOBAR, DOOBAR, ? FROM TABLEB And then send this to JDBC via Spring JDBC to update... simpleJdbcTemplate.update( mySqlFromAbove, someVariableToReplaceQuestionMark ); Is this even possible? It would work fine if I replace the question mark wi...

JDBC connection to very busy SQL 2000: selectMethod=cursor vs selectMethod=direct?

In the process of trying to help out an app dev team with performance issues on a SQL 2000 server (from a bunch of Java applications on separate app servers), I ran a SQL trace and discovered that all calls to the database are full of API Server Cursor statements (sp_cursorprepexec, sp_cursorfetch, sp_cursorclose). Looks like they're s...

Network latency under Hibernate/c3p0/MySQL.

I'm connecting to a MySQL (InnoDB) database over a connection with fairly high latency (~80ms) but relatively high bandwidth. I've noticed that query times vary dramatically depending on how the query is issued. In the following examples I'm performing a query for a single, small row by primary key. The query times are: Command line...