jdbc

In-memory database close()

In an in-memory database, is it necessary to close ResultSets, Statements and Connections? My Java program uses HSQLDB to create a "memory table" and populate it with data, which it later queries. There is no persistence. Everything is done in memory. The program is single-threaded and only has one database connection (i.e. no database...

Problems with string parameter insertion into prepared statement

Hi, I have a database running on an MS SQL Server. My application communicates via JDBC and ODBC with it. Now I try to use prepared statements. When I insert a numeric (Long) parameter everything works fine. When I insert a string parameter it does not work. There is no error message, but an empty result set. WHERE column LIKE ('%' ...

Problem with updating using Spring's JdbcTemplate

I've a function updating database table using Spring's JdbcTemplate and for some reason there was exceptin that connection is read only u can not update any database related changes. How to resolve these problem? ...

SimpleJdbcTestUtils.executeScript and multilines script

Hi, I want to load SQL script files for my unit tests. As I am using Spring 2.5.2, I decided to use the SimpleJdbcTestUtils.executeScript() method to load my script file, using the following code: DriverManagerDataSource dataSource = ... // getting my DataSource defined in my Spring context SimpleJdbcTemplate template = new SimpleJdbcT...

About the connectivity to IBM database using JDBC in Java

I have a problem connecting to IBM (universal) database using JDBC. I wrote the code in Notepad using Java and I loaded drivers of IBM database i.e(driver name and connection URl). When I run the code using general compilation (javac code.java and java code) I am getting an error message "cannot find the driver" but I specified the corr...

How do you handle these common problems WITHOUT using an ORM and using straight JDBC (or equivalent)?

Wnen using just JDBC, I typically have to think about the following problems. I don't think too hard and just make something work, but I am wondering how people handle these without an ORM or other library. Eager vs Lazy Loading: Do you just have a single domain object and have the dependent children be null and make it the responsibil...

MySQLNonTransientConnectionException in jdbc program at run time

Hi I have created jdbc mysql connection. my program works fine for simple execution of query. But if i run the same program for more than 10 hour and execute query then i receives the following mysql exception. I have not used close() method anywhere. i created database connection and opened it forever and always execute query. there i...

Oracle UPDATE command with multiple conditions in Java

Hello I'm having issues with the Java code below. It is supposed to update certain records in a table where the ID is given, and where the STATUS column is 'good' (this is only one row at any given time). However, when I run the code below, it seems to be ignoring the AND STATUS = 'good' part, and updating all NUMRECS wherever the ID ma...

Java Large database inserts

I have a database in which I need to insert batches of data (around 500k records at a time). I was testing with derby and was seeing insert times of about 10-15minutes for this many records (I was doing a batch insert in Java). Does this time seem slow (working on your average laptop)? And are there approaches to speeding it up? thanks...

How should I connect to a MySQL data source from Eclipse?

I have an external MySQL server that's set up and working fine. I created a database connection in Eclipse and can view the database in the Data Source Explorer tab. Now, I have a servlet that needs to access that database. How do I do it? Is there a way to reference that database connection created in the data source explorer, or do...

Where should I setup a Database connection in Struts 2 app ?

I am developing a small web application using struts 2. I want to setup a database connection when the web application starts. After that, I want that database connection object to be used in the the entire web application to update records in the database server. Where should I include the database connection setup code in my struts2 ...

java.util.Date vs java.sql.Date

java.util.Date vs java.sql.Date: when to use which and why? ...

Editing JTable from RestulSet Table

Continuing this question. My problem is that I can not edit my JTable. I get an exception and the Object value instead of what I should be seeing. I am using the ResultSet Table code with a MS-Access database and with a few modifications. My code can be found here. I run into an error when I rs.updateRow() is called. java.sql.SQLExcept...

Named parameters in jdbc

Are there named parameters in JDBC instead of positional ones, like the @name, @city in ADO.NET query below ? select * from customers where name=@name and city = @city ...

Restrict access to connection pool in Weblogic?

In short, how can I restrict access to connection pool X based on application name or JAR name? A simple use case might help... A business web-app (call it WEB_APP_A) uses pool Y to do basic look-up SQL. Some users of this web-app have access to also update some sensitive data in the database. This code is provided by a JAR file (call i...

JDBC MySql Connection Pooling practices

I have a Java-JSF Web Application on GlassFish, in which I want to use connection pooling. Therefore I created an application scoped bean that serves with Connection instances for other beans: import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; import javax.naming.Context; import javax.naming.InitialCo...

connection timed out error while deploying spring app

I’m trying to deploy a simple Spring app and getting a “connection timed out ” error. My app tries to take a text input from the user in one jsp, insert that value under username in the db and then display that name in another jsp along with a greeting eg: "hello, " My environment: OS: Windows XP professional Server : Tomcat 6 IDE: ...

I want to convert a resultset to a string. I have tried everything but it always gives no data found. Please provide some solution

I want to convert a ResultSet to a string. I have tried everything but it always gives no data found. Please provide some solution ...

What could be the possible cause of this exception?

I get the following error when I run a java program: Exception in thread "main" java.lang.UnsatisfiedLinkError: t2cPingDatabase at oracle.jdbc.driver.T2CConnection.t2cPingDatabase(Native Method) at oracle.jdbc.driver.T2CConnection.doPingDatabase(T2CConnection.java:503) at oracle.jdbc.driver.PhysicalConnection.pin...

Data type not found error in JDBC connection in java?

I am using Microsoft Access database for storing data. In that, I stored date as "DATE/TIME" data type. While getting date from the following code it produces error.. String sql = "Select prev_date from StaffAdvance where Staff_ID='"+date+"'"; ResultSet rs = st.executeQuery(sql); What is wrong with t...