jdbc

Public SQL database for educational purposes

I am looking for a publicly available SQL database with free access, where one can run some SELECT queries for free on some meaningful data (not item1, item2, item3). Have you seen any? Even better if it came together with some tutorial. Vendor is not that relevant, as long as one can connect using a generic JDBC client. ...

Pattern for creating a database schema using JDBC

I have a Java-application that loads data from a legacy file format into an SQLite-Database using JDBC. If the database file specified does not exist, it is supposed to create a new one. Currently the schema for the database is hardcoded in the application. I would much rather have it in a separate file as an SQL-Script, but apparently t...

Hibernate Communications Link Failure in Hibernate Based Java Servlet application powered by MySQL

Let me describe my question - I have a Java application - Hibernate as the DB interfacing layer over MySQL. I get the communications link failure error in my application. The occurence of this error is a very specific case. I get this error , When I leave mysql server unattended for more than approximately 6 hours (i.e. when there are ...

How to set logging level for JDBCDriverLogging

I am trying to change the logging level to stop showing millions of this: <May 26, 2010 10:26:02 AM EDT> <Debug> <JDBCDriverLogging> <000000> <2336: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |> I have tried adding this to my java line: -Djava.util.logging.config.file=/foo/bar/logging.properties With this as ...

Retrieving Oracle Cursor with JDBC

I have been experiencing some frustrations trying to make a simple Oracle cursor retrieval procedure work with JDBC. I keep on getting an error of "[Oracle][ODBC][Ora]ORA-06553: PLS-306: wrong number or types of arguments in call to 'GETNAME'", but I cannot figure out what I am doing wrong. Here is my code in Java: CallableStatement s...

Using a PreparedStatement to persist an array of Java Enums to an array of Postgres Enums

I have a Java Enum: public enum Equipment { Hood, Blinkers, ToungTie, CheekPieces, Visor, EyeShield, None;} and a corresponding Postgres enum: CREATE TYPE equipment AS ENUM ('Hood', 'Blinkers', 'ToungTie', 'CheekPieces', 'Visor', 'EyeShield', 'None'); Within my database I have a table which has a column containing an array of "equi...

PreparedStatement.setString() method without quotes

I'm trying to use a PreparedStatement with code similar to this: SELECT * FROM ? WHERE name = ? Obviously, what happens when I use setString() to set the table and name field is this: SELECT * FROM 'my_table' WHERE name = 'whatever' and the query doesn't work. Is there a way to set the String without quotes so the line looks like t...

INSERT SQL in Java

Hello. I have a Java application and I want to use SQL database. I have a class for my connection : public class SQLConnection{ private static String url = "jdbc:postgresql://localhost:5432/table"; private static String user = "postgres"; private static String passwd = "toto"; private static Connection connect; pub...

Why is retreiving a ResultSet from Oracle stored procedure soooo slow ?

I have to improve some code where an Oracle stored procedure is called from a Java program. Currently the code is really really slow : up to about 8 seconds on my dev machine. On the same machine, if I call directly a SQL query that does about the same treatment and returns the same data, it takes under 100 ms... The code creates a Call...

NoClassDefFound error - Spring JDBC

Right now, I'm compiling my .class files in eclipse and moving them over to my %tomcat_home%\webapps\myapp\WEB-INF\classes directory. They compile just fine. I also have in the ...\classes directory a org.springframework.jdbc-3.0.2.RELEASE.jar which I have verified has the org.springframework.jdbc.datasource.DriverManagerDataSource clas...

Use different version of derby.jar then the one included with WebSphere?

I’m trying to use an imbedded Derby database from within a war file deployed on WebSphere for Z/OS. When I use code like the following to create a database I wind up creating a derby version 10.3 database using the derby.jar included with WebSphere server 7.0 instead of the version 10.5 derby.jar I include in my WEB-INF/lib directory. C...

JdbcTemplate — logging the dataSource connection url

Hi, is there a way to log the JdbcTemplate's DataSource connection URL in Java? The field exists in the DataSource, but there ain't a getter to access it. Of course I could read the DataSource properties from the application context xml, but I'd like to do it the other way. ...

How do I get output into Java from a SELECT stored procedure in Oracle?

I'm using Java to connect to an Oracle 10 Database. I want to create a stored procedure (don't ask why) that takes no arguments and returns a lot of rows. Specifically, in Java I want to be able to get this data with something like: ResultSet rs = stmt.executeQuery("call getChildless"); where getChildless is the query: SELECT objecti...

converting result set to list

how can i conver result set to list? i am using following code but its not working properly private List<User> convertToList(ResultSet rs) { List<User> userList = new ArrayList(); User user = new User(); try { while (rs.next()) { user.setId(rs.getInt("id")); user.setU...

Store date object in sqlite database

Hello, I'm using a database in my Java project and I want to store date in it, the 5th and the 6th parameter are Date Object. I used the solution below but I have errors in the indicated lines: PreparedStatement creerFilm = connecteur.getConnexion().prepareStatement( "INSERT INTO FILM (ID, REF, NOM, DISTRIBUTEUR, DATEDEBUT, DAT...

problem using base64 encoder and InputStreamReader

I have some CLOB columns in a database that I need to put Base64 encoded binary files in. These files can be large, so I need to stream them, I can't read the whole thing in at once. I'm using org.apache.commons.codec.binary.Base64InputStream to do the encoding, and I'm running into a problem. My code is essentially this FileInputStre...

How to find out if a Java ResultSet obtained is empty?

Class.forName("org.sqlite.JDBC"); Connection conn = DriverManager.getConnection("jdbc:sqlite:userdata.db"); Statement stat = conn.createStatement(); ResultSet rs = stat.executeQuery("SELECT * from table WHERE is_query_processed = 0;"); int rowcount = rs.getRow(); System.out.println("Row count = "+rowcount); // output 1 rs.first()...

Are there any issues with MySQL's i18n(indic language) support ?

Hi All, We're evaluating MySQL and PostgreSQL for building our indic language(using utf-8 encoding) web application which will use MySQL or PostgreSQL. One of my colleagues mentioned that MySQL had issues with i18n. I mostly come from the Oracle world and although I've played a lil with MySQL, I don't know enough to know that there are...

Check if table exists

I have a desktop application with a database embedded in it. When I execute my program I need to check that specific table exists, or create it if not. Given a Connection object named conn for my database, how could I check this? ...

How can I escape '"' when reading a csv-file with JDBC?

I am reading a csv-file with JDBC, using CsvJdbc. Some strings in the csv-file contains a "-char, how can I handle these situations? When I am reading the csv-file with: while (results.next()) { String name = results.getString("Name"); ... } I get this SQLException, on the line where I have while (results.next()) { java.sql....