jdbc

Is this use of PreparedStatements in a Thread in Java correct?

I'm still an undergrad just working part time and so I'm always trying to be aware of better ways to do things. Recently I had to write a program for work where the main thread of the program would spawn "task" threads (for each db "task" record) which would perform some operations and then update the record to say that it has finished. ...

java improper cyrillic string

Hi, I use JExcel API to read excel file and then I stored them into an ArrayList. Then I insert them into a database. My array list contains cyrillic strings and the problem is these strings do not have inserted into database properly. As long as I have seen, other people can print out cyrillic strings into a standard output properly bu...

How does jdbc work

can anyone tell me How does jdbc work? How it manages to communicate with a DBMS? since DBMS may be written with some other programming language. ...

java.sql.SQLWarning: [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to X

Hi all, I'm using Hibernate 3.2.1 and database SQLServer2000 while I'm try to insert some data using my dao, some warning occurred like this: java.sql.SQLWarning: [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to BTN_SPP_DB at com.microsoft.jdbc.base.BaseWarnings.createSQLWarning(Unknown Source) at com.microsoft....

How to get descriptive error messages from DB2?

When I call a SQL statement via JDBC on the DB2 and the statement fails, I catch an SQLException with the following message text: com.ibm.db2.jcc.a.nn: DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703, SQLERRMC=O.METADATENSATZ, DRIVER=3.52.95 I tried an automatic translation of the message according to the error list published by IBM, ...

What is the best way to iterate over a large result set in JDBC/iBatis 3?

We're trying to iterate over a large number of rows from the database and convert those into objects. Behavior will be as follows: Result will be sorted by sequence id, a new object will be created when sequence id changes. The object created will be sent to an external service and will sometimes have to wait before sending another one...

Connecting to hosted MySQL server with Java

Hi, I've been recently trying to connect to a hosted MySQL using Java but can't get it to work. I can connect to a local MySQL with localhost using: connect = DriverManager.getConnection("jdbc:mysql://localhost/lego?" + "user=******&password=*******"); (Replacing the astrisks withmy username and password) I can conne...

Using JDBC driver to connect with Sql Server 2008

I'm using following code to connect with Sql Server 2008: Connection con = null; CallableStatement stmt = null; ResultSet rs = null; try { SQLServerDataSource ds = new SQLServerDataSource(); ds.setIntegratedSecurity(false); ds.setServerName("localhost"); ds.setInstanceName("MSSQLSERVER2008"); ds.setPortNumber(1433);...

updateBinaryStream on ResultSet with FileStream

If I try to update a FileStream column I get following error: com.microsoft.sqlserver.jdbc.SQLServerException: The result set is not updatable. Code: System.out.print("Now, let's update the filestream data."); FileInputStream iStream = new FileInputStream("c:\\testFile.mp3"); rs.updateBinaryStream(2, iStream, -1); rs.updateRow(); iStr...

c3p0 acronym origin - jdbc connection pool name

Can anyone share the origin and meaning of the jdbc connection pool named c3p0. Was it inspired from star wars?. ...

XA vs. Non-XA JDBC Driver Performance?

We are using an XA JDBC driver in a case where it is not required (read-only work that doesn't participate in a distributed transaction). Just wondering if there are any known performance gains to be had to switch to the Non-XA JDBC driver - if not it's probably not worth switching? FWIW we are using MySQL 5.1 ...

Simple select not working on JDBC SQL Server?

I am trying to move project which was using MySQL database to the one that uses SQL Server 2008, But the select that was working in mysql is no longer working in SQL Server PreparedStatement statement = connection .prepareStatement("select u.user_firstname,u.user_lastname from user_details u, login l where l.username...

What is JDBC's Connection.isClosed() good for, and why is Snaq DBPool misbehaving on close?

I have the following code in Java: if(!conn.isClosed()) { conn.close(); } Instead of working, I am awarded with: java.sql.SQLException: Connection already closed My connection object is a Snaq.db.CacheConnection I checked the JavaDocs for isClosed, and they state that: This method generally cannot be called to determine w...

Is there a way to find out a database cursor is open or not in Java?

Is there a way in JDBC to find out the cursor opened or not in JAVA. We are getting an exception when tried to access an un opened cursor. java.sql.SQLException: Cursor is closed. Here is what is happening. The Stored proc is designed this way. the proc returns the cursor and a couple of other columns. For some conditions, the DB guy i...

How to migrate data from FoxPro to MySQL

I am having a database in .dbf (FoxPro) format. How to retrieve data from FoxPro using Java? If the data can be migrated to MySQL, How to do the conversion? ...

using JDBC with persistence.xml

I am building a framework that manage the access to the database. the framework getting tasks from the user and handle a connection pooling that manage the access to the database. the user just send me SQL commands. One of the feature that i would like to support is working with JPA, in this case i will provide entity manager. in some ...

org.postgresql.util.PSQLException: FATAL: sorry, too many clients already

hi im using postgresql database, I want to insert my datas into database,but whenever i run the server,it was display the following Error. Error:org.postgresql.util.PSQLException: FATAL: sorry, too many clients already How to solve this problem.My server.properties file is following. Sever.properties File: serverPortData=9042 serverP...

How best to modernize the 2002-era J2EE app?

I have this friend.... I have this friend who works on a java ee application (j2ee) application started in the early 2000's. Currently they add a feature here and there, but have a large codebase. Over the years the team has shrunk by 70%. [Yes, the "i have this friend is". It's me, attempting to humorously inject teenage high-school c...

Insert a record with a value partly from another table

I have two tables, Proteins and Species. Protein has Species.Id as foreign key constraint. When I insert the data, I know the name of the species that protein belongs to, but not the Id. So I do the following: PreparedStatement query = connection.prepareStatement( "SELECT Id FROM Species WHERE ShortName = ?"); query.setS...

Error with connection in my database servlet

Hello, I am writing a Database servlet, all seems well except that there seems to be an error in my connection import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Arra...