jdbc

JDBC: Does the connection break if i lose reference to the Connection object?

Hi. If i have the following method - public static void C() { Connection con = DriverManager.getConnection(); .... // code return; } and i dont call con.close() , will the connection terminate automatically once the method returns? ...

The big last_insert_id() problem, again.

Note - this follows my question here: http://stackoverflow.com/questions/2983685/jdbc-does-the-connection-break-if-i-lose-reference-to-the-connection-object Now i have a created a class so i can deal with JDBC easily for the rest of my code - public class Functions { private String DB_SERVER = ""; private String DB_NAME = "tes...

Tomcat Postgres Connection

Hi, I'm using a singleton class for a PostgresSQL connection inside a servelet. The problem is that once it is open it works for a while (I guess until some timeout), and then it starts throwing a I/O exception. Any idea what is happening to the singleton class inside Tomcat VM? Thanks ...

JDBC Connection pool monitoring GlassFish

I am trying to find a setting by which the connection pool monitoring information would come in the server.log whenever an error like "error allocating a connection" or "connection closed" occur. I found some blog entries that talk about this but they mention it from GUI prespective. However, I want a setting on the connection pool i...

java.sql.Exception ClosedConnection

I am getting the following error: java.sql.SQLException: Closed Connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208) at ...

Using prepared statements with JDBCTemplate

Hi. I'm using the Jdbc template and want to read from the database using prepared statements. I iterate over many lines in a csv file and on every line I execute some sql select queries with it's values. Now I want to speed up my reading from the database but I just can't get the Jdbc template to work with prepared statements. Actually...

What is Jdbc type 5 driver

What is a JDBC type 5 driver? What are the benefits of such a driver? Can I get any links/tutorials about type 5 drivers? ...

How can I get an error or a warning from a PreparedStatement?

I had an update like this: update table set col1=?,col2=?,col3=? where col4=?; and I filled it up like this: statement.setString(1,"some_value"); statement.setString(2,"some_value"); statement.setString(3,"some_value"); and I forgot to add a fourth value.I did a executeUpdate and of course nothing happened to the database. I spent ...

Invoking a PL/SQL function from EclipseLink

I'm trying to execute a PL/SQL function in EclipseLink which uses Oracle Specific types(eg. Boolean). I've tried using PLSQLStoredProcedureCall which complains that I'm not executing a procedure and I have tried using StoredFunctionCall but that returns PLS-00382: expression is of wrong type Has anyone developed a solution to invoke ...

JDBC batch insert performance

I need to insert a couple hundreds of millions of records into the mysql db. I'm batch inserting it 1 million at a time. Please see my code below. It seems to be slow. Is there any way to optimize it? try { // Disable auto-commit connection.setAutoCommit(false); // Create a prepared statement String ...

Detect Database Currently in Use with Java

Is there a way to detect the ODBC database currently being connected to with Java? For example, I would like to know whether an application is currently connected to Oracle 10g or SQL Server 2005. Thanks in advance. ...

JSP does not insert my data into database

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> <%@ page import="java.io.*"%> <%@ page import="java.io.File"%> <%@ page import="java.util.*"%> <%@ page import="java.sql.*"%> <%@ page import="java.sql.Blob"%> <%@ page import="java.sql.PreparedStatement"%> <%@ page import="java.sql....

Handling unexpected end of requests in servlets

Hi, I am currently developing a REST web service with Jersey / Tomcat (but a generic Servlet/Container answer is welcome). If the client does some GET requests on services that return large amount of data, from a MySQL connection. To avoid any OOM exception, I use a streaming mode for MySQL. However, if the client aborts the request ...

stored procedures in scala.dbc

I wonder if scala.dbc supports stored procedures? The mysql jdbc backend I'm using supports it, bonus points for a code illustration to show how it works. ...

problem with unicode in javaEE and save question mark in database

when i insert persian information with use JEE6(JSF and JPA) my information save question mark for example "علی" ===> "???" my database is Mysql and my table is UTF-8 . when insert persian data directly in database is correct and save correct. i know that with change one property in JEE my problem go to solved but i don`t know where ...

java.lang.OutOfMemoryError: Java heap space

i get this error when calling a mysql Prepared Statement every 30 seconds this is the code which is been called: public static int getUserConnectedatId(Connection conn, int i) throws SQLException { pstmt = conn.prepareStatement("SELECT UserId from connection where ConnectionId ='" + i + "'"); ResultSet rs = pstmt.executeQuery();...

Jython CLASSPATH, sys.path and JDBC drivers

How can I add JDBC drivers at runtime to Jython? Using CLASSPATH works, but using sys.path doesn't work with zxJDBC even though the class is imported fine and can be manipulated from the Jython interpreter prompt. Why does this work: $ CLASSPATH=/tmp/jtds\-1.2.5.jar ./jython *sys-package-mgr*: processing new jar, '/private/tmp/jtds-1.2...

how to specify null value in MS Access

I am not able to call setNull on PreparedStatement using MS Access (sun.jdbc.odbc.JdbcOdbcDriver) preparedStatement.setNull(index, sqltype). Is there a workaround for this. For LONGBINARY data type, I tried the following calls, neither worked. setNull(index, java.sql.Types.VARBINARY) setNull(index, java.sql.Types.BINARY) java.sq...

Is it expensive to hold on to PreparedStatements? (Java & JDBC)

I'm trying to figure out if it's efficient for me to cache all of my statements when I create my database connection or if I should only create those that are most used and create the others if/when they're needed.. It seems foolish to create all of the statements in all of the client threads. Any feedback would be greatly appreciated....

building a web application in eclipse

As a concluding assignment for the technologies taught in a data management course, we have to write a web application using the technologies taught throughout the course, this mostly includes xhtml, css, JSP, servelets, JDBC, AJAX, webservices. the project will eventually be deployed using tomcat. we are given the option of choosing the...