jdbc

What would cause this query to stop working?

I'm working with a legacy Java app that's pulling data from Oracle. One of the queries appears to no longer work: select {hier.*} from ecadmin.dept_hier_cache hier connect by prior parent_deptid = deptid start with deptid = '1234'; When I remove the '{}' brackets from around hier.*, everything works as normal. Now, as far as I can tel...

Retrieve an Image stored as BLOB on a MYSQL DB

Hi folks I'm trying to create a PDF based on the information that resides on a database. Know I need to retrieve a TIFF image that is stored as a BLOB on a mysql database from Java. And I don't know how to do it. The examples I've found shows how to retrieve it and save it as a File (but on disk) and I needed to reside on memory. Table...

Spring's Stored Procedure - results coming back from procedure always empty.

Hi, I am using Spring's JdbcTemplate and StoredProcedure classes. I am having trouble getting the stored procedure class to work for me. I have a stored procedure on an oracle database. Its signature is CREATE OR REPLACE PROCEDURE PRC_GET_USERS_BY_SECTION (user_cursor OUT Pkg_Types.cursor_type , section_option_in IN Varchar2 , se...

MS Jdbc driver sqljdbc 2.0 driver fails to connect to SQL Server 2008

Hi all, We have a well-defined problem that points to a problem with Microsoft's JDBC 2.0 driver for JDK 1.6 ("sqljdbc4.jar"). I may be wrong. I've been wrong before. I wanted to see if I'm missing anything. any insights? Anyone seen this before? Usecase: use ant "sql" task to run a simple sql query. All queries fail jdbc driver...

How do I get a Double out of a resultset instead of double?

When working with a JDBC resultset I want to get Double instead of double since this column is nullable. Rs.getDouble returns 0.0 when the column is null. ...

How can I access an Interbase (.IB) database using pure JDBC?

I have a .IB file which I'd like to access using a Java Application. Where can I find the drivers for Interbase. My OS is Mac OS X ...

Entity Bean finder methods VS DAO ?

Will there be a performance improvement if I remove the entity bean (finder methods) and introduce the DAO layer instead. I want to do this mainly for reading data from the DB. I have a process in my project which has around 15 entity beans finder call in the flow, so if I remove the Entity beans or introduce a DAO and leave the entity b...

How do I go about creating and then connecting to and querying a database in Java?

I've recently started my first programming job, and what I need to do as my main project is to create a program for simulating diesel generator behaviour. I'm creating this program using Java, which I've never used before (all of my limited experience is with C++), and the first problem I need to overcome is to create a database to stor...

Simple database web application with Eclipse and Glassfish

Hello I just started to learning Eclipse with Glassfish server. I was looking around how can I make simple database web application, but can't figure out yet. I downloaded the Glassfish bundle for Eclipse. I need to create simple database ( perhaps one table ), and connect the database with simple web application. How to do that in Ec...

Safe to convert Java.sql.date to Java.util.date by up casting?

The title says it all. Java.sql.date extends java.util.date, so is it save to convert between the two by casting a java.sql.date as a java.util.date? Or is there some other way to convert them? ...

Clojure MySQL Syntax Error Exception ("[...] near '????????????????' [...]")

Hi there, I'm having trouble doing anything with clojure.contrib.sql beyond establishing a connection. I have a mysqld running on localhost:3306 with a database called clj_db. The user 'clj_user'@'localhost' with password 'clj_pass' can access this database. When trying to "select * from clj_table" I get a "com.mysql.jdbc.exceptions.M...

How to connect XAMPP MySQL local DB using JDBC?

I have this Tetris game written in Java, which uses DB to record high scores. It worked ok as long as I was using remote MySQL DB, but now I'm trying to set up localhost DB using XAMPP MySQL and it keeps going like "SQLException: Communications link failure" at command: con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/...

How to use Java JDBC connection pool?

I want to use a JDBC connection pool. The most important factor is that it's easy-to-use and bug-free. What is suitable for me? ...

Using Spring JDBC for Oracle Stored Procedure I get a ORA-02055 when SP throws ORA-20118

ORA-20118 is a custom exception from the stored procedure. The stored procedure runs just fine from PL-SQL developer, so the problem is in Spring. What I need to do is to get Spring to rollback the SP when it gets the ORA-20118 exception back from the SP. How do I do that? or maybe just get spring to correctly handle the 20118 code c...

Handling large records in a J2EE application

There is a table phonenumbers with two columns: id, and number. There are about half a million entries in the table. Database is MySQL. The requirement is to develop a simple J2EE application, connected to that database, that allows a user to download all numbervalues in comma separated style by following a specific URL. If we get all ...

insert a picture into database(sqlite) with java code. what should i do?

in the sqlite database, i set a field typed blob. then, i wrote java code: PreparedStatement preStmt = con.prepareStatement("INSERT INTO zz(pic) VALUES(?)"); preStmt.setBinaryStream(1, new FileInputStream(file), file.length()); i got a exception: java.lang.AbstractMethodError: org.sqlite.PrepStmt.setBinaryStream(ILjava/io/InputStrea...

What are likely causes of StringBuilder and ResultSet performance issues

I'm looping through a ResultSet in Java; which for testing purposes is returning about 30 rows with 17 Columns (all String data) per row. I'm manually building an XML String out of the results using StringBuilder and its literally taking about 36 seconds for the loop to finish these iterations. Note: I realize this isn't the best way to...

How to use Oracle SQLdeveloper with HSQL / Hypersonic DB's JDBC driver

I'd like to use Oracle's SQLdeveloper to visualize my HSQLDB tables. An instruction on how to use it with MySQL can be found on http://blogs.techrepublic.com.com/programming-and-development/?p=564 ... and I know that Oracle points to a location where to download all JDBC drivers. With MySQL this worked, however, including the JAR file ...

How to overcome "java.sql.SQLException: Too many connections" exception?

I have a simple web application written in java which has servlets accessing the Mysql Database to generate reports. The report generation happens very frequently. I am using the apache commons DBCP to get connections to the DB. I also close the connection explicity in the finally block always. But i do not explicitly close the Stateme...

Fastest 'update' on jdbc with PreparedStatement and executeBatch

I have a java program that in some circumstances must update a large amount of records in a database (e.g 100,000). The way it does it is by creating a PreparedStatement and by using the addBatch technique. Here is the snippet: connection.setAutoCommit(false); PreparedStatement ps = connection.prepareStatement( "UPDATE myTable...