jdbc

MySQL and SQLite differences in SQL

I'm writing java application that is using both SQLite and MySQL using JDBC. Are there any differences in SQL for those databases? Can I use same queries for both SQLite and MySQL, or is there any db specific stuff, that doesn't work on the other one? As far I've worked only with MySQL, so I don't really know much about SQLite. ...

Why is the Sybase JDBC driver "eating" the exceptions?

I'm using the official Sybase JDBC driver to connect to a database and call a stored procedure by creating a CallableStatement, binding the parameters to it and calling .execute() on it. However, I found that no exception is thrown, even if the stored procedure fails. I can verify that the failure is propagated back to me by sniffing th...

How to connect to Oracle using JRuby & JDBC

First approach: bare metal require 'java' require 'rubygems' require "c:/ruby/jruby-1.2.0/lib/ojdbc14.jar" # should be redundant, but tried it anyway odriver = Java::JavaClass.for_name("oracle.jdbc.driver.OracleDriver") puts odriver.java_class url = "jdbc:oracle:thin:@myhost:1521:mydb" puts "About to connect..." con = java.sql.DriverMa...

MYSQL & Java Applet

Hello, I am currently changing a java desktop application over to a java applet. Everything is working fine, but as soon as the applet attempts to make a mysql database call, it does not work. The code in the desktop application is fine, but as soon as its called from the application its not working. Do any changes need to be made to t...

Where do you put your SQL Queries?

We are using a mix of EJB 2.1 and JDBC to access our Database. I just had a co-worker mention the idea to put his SQL Queries into a .properties file. How and Where do you put your SQL Queries? EDIT: Do you inline it with the code, put into the class instantiation? ...

getBytes vs getBinaryStream vs getBlob for getting data out of a BLOB column

There are 3 different ways to get data out of a Blob column: getBytes getBinaryStream getBlob Also, the Blob object returned by getBlob also has a getBytes and getBinaryStream on it. Are there any particular reasons (performance, memory, database specific problems) that I should pick one over the other? The Blob object also has a fre...

How do I Insert values into a Microsoft Access Database through JDBC?

I have created a letter game in Java and I need to include a high score function in it using a Microsoft Access database through JDBC. The table in the database contains the following fields Table Name: Scores Name (Text) Difficulty (Text) Characters (Number) Accuracy (Text) Time (Text) Score (Text) I need a SQL st...

how to fetch data from a Microsoft Access database through JDBC and insert the table as a test field in an Applet

hi!! I have made a small letter game in a Java Applet. I have made a microsoft access database through jdbc for the high scores. I hav managed to insert values(scores) into the database but i hav truble in fetching them and display the table in a textArea of ajFrame. I am not even sure if the connection is established. I hav created the ...

Database Migration

I am working on database migration tool in java. The tool is copying database tables with their data's to the destination database. But i want it to work on different databases. Copy from mysql and create in derby etc. With JDBC, we can gather enough information about the table and its columns. But i am going to ask this, if i can recrea...

jdbc performance testing for getting CLOB/BLOB data

I am trying to compare the performance of the different calls (getBytes/getBinary/getBlob) for getting data out of a BLOB column. What I am doing right now is tracking the time to execute the statement via the jdbc driver and iterating through the resultset. //Mark time ResultSet resultSet = stmt.executeQuery(query); resultSet.getByte...

How do I get at the sql statement that caused an SQLException using the Postgres JDBC driver in Java?

Background In my current project - a server product with no GUI front-end, I'm trying to write in better error handling support. Errors currently are outputted to the logs and are typically not read by users. We use PostgreSQL as our database backend and we access it using direct JDBC calls and DAOs via a database pooler. Most database...

Application using Pooled JDBC Connections

I'm working with a legacy WebLogic application that contains a web-service application and a standalone, command-line application. Both need access to a common database and I would like to try and get the command-line application use a pooled connection to the web-server's JDBC connection. (The standalone application can only be run wh...

Load Java classes based on a classpath in a properties file

My application uses JDBC database drivers. I load these from a jar file, db2jcc.jar in the case of DB2 which I'm currently working with. With this jar in the classpath, everything is fine, but I have a requirement to find the jar from a property in the application's config file instead - for example, database.driver=/opt/IBM/db2/V9.5/j...

ResultSet method "last" is this an optimal way?

I have this java code which does this ResulSet rs = stmt.executeQuery(); while (rs.next()) { .... //do regular processing if (rs.last()) { //do last record processing } } ...

Controlling JMS Server: too many MDBeans created (weblogic)

I have an application that does a delayed operation. User generates 1 million messages that are stored in the JMS Queue and then a MDBeans are consuming these messages and performing some action and storing data in the database. Since JMS Queue is working too fast, it tries to create 1 million MDBean instances which in turn try to create...

Display 100000 records on browser / multiple pages.

I would like to display 100000 records on browser / multiple pages with minimal impact on memory. ie Per page 100 records. I would like to move page back and forth. My doubts are 1. Can I maintain all the record inside the memory ? Is this good Idea ? 2) Can I make database connection/query for ever page ? If so how do write a query? ...

Streaming Data through Spring JDBC, unknown length

I currently have an application that inserts byte[] into our DB through the use of Spring JDBC [SqlLobValue]. The problem is, this is not a scalable way to take in data, as the server is buffering all the data in memory before writing to the database. I would like to stream the data from the HttpServletRequest Inputstream, but all the ...

Named pipes versus TCP for JDBC-MySQL in Windows

I've been having numerous connection problems between my Java (JPA+Hibernate+CommonsDBCP) app connecting to MySQL. I've done the research, tweaked all the settings with validation queries, timeouts, tests before X, etc. This path led me to another StackOverflow question comparing DBCP and C3PO. From the responses, I've decided to defini...

handling DATETIME values 0000-00-00 00:00:00 in JDBC

I get an exception (see below) if I try to do resultset.getString("add_date"); for a JDBC connection to a MySQL database containing a DATETIME value of 0000-00-00 00:00:00 (the quasi-null value for DATETIME), even though I'm just trying to get the value as string, not as an object. I got around this by doing SELECT CAST(add_date A...

How to load Java Stored Procedure through JDBC into Oracle 10g?

I'm trying to load some java stored procedures into an Oracle 10g database through JDBC. The statement I'm executing is - CREATE OR REPLACE JAVA SOURCE NAMED "test.Test" AS package test; public class Test { public static String myMethod(String a) { return a; } }; Running this through TOAD works just fine, but when running...