jdbc

Requirements for connecting to Oracle with JDBC?

I'm a newbie to Java-related web development, and I can't seem to get a simple program with JDBC working. I'm using off-the-shelf Oracle 10g XE and the Eclipse EE IDE. From the books and web pages I've checked so far, I've narrowed the problem down to either an incorrectly written database URL or a missing JAR file. I'm getting the fo...

how do I make a select which always returns zero rows

I want to determine if a column exists in a table for any jdbc driver. In order to know the columns in a table, I have to make a query to the table and then get the ResultSetMetaData for the info, but this is pretty expensive in like 99% of times. In mysql I have: SELECT * FROM tablename LIMIT 0,0 In Intersystems caché I have: SELEC...

Does Oracle support Server-Side Scrollable Cursors via JDBC??

Hi all Currently working in the deployment of an OFBiz based ERP, we've come to the following problem: some of the code of the framework calls the resultSet.last() to know the total rows of the resultset. Using the Oracle JDBC Driver v11 and v10, it tries to cache all of the rows in the client memory, crashing the JVM because it doesn't...

MDE Access decrypt JDBC

I want to perform JDBC SQL queries on a MDE Access file. I've set up the data source ODBC and everything worked well for a MDE file. Now, I'm working with a newer version of the MDE file, and here is the result: java.sql.SQLException: [Microsoft][Driver ODBC Microsoft Access] Cannont read record. Read authorization unavailable for "tbl...

JDBC with MySQL really slow, don't know why

Hi guys, I have a problem with a really slow connection between my Java code and a MySQL Database. I don't know where the bottle neck is. My program is more or less a chatbot. The user types something in, my program splits the sentence into words and sends it word per word to the database. If it finds something there, the user gets an ...

Concurrent queries on a given JDBC connection?

I'm seeing OraclePreparedStatement executeQuery() exhibit serialization. That is, I have two queries that I want to run concurrently against an Oracle database, using the same connection. However, the OraclePreparedStatement seems to explicitly prohibit concurrent queries. My question is: Is this serialization a necessary artifact of...

How commons dbcp (and other connection pools) manage open statements and resultsets?

Specifically, when I return a connection to the pool, does dbcp (and other connection pools) close the statements and resultsets for me? Or should I be closing these myself? ...

Create a wrapper for java.sql.Connection that works with JDBC 3 and 4

Is there some hack to create a wrapper for java.sql.Connection which works with JDBC 3 and 4 (Sun added a couple of methods and new types to the interface for JDBC 4) without resorting to something which patches the source at compile time? My use case is that I need to generate a library which works with Java 5 and 6 and I'd really like...

How to deploy JDBC client app via WebStart ?

Hi all, I know that this is a very helping community.. so i hope I will get an answer for my problemt. Actually, I have a swing app which contacts an oracle database via JDBC. Now I want to deploy this via WebStart. I have a text area in the application that prints out the log messages . all goes well, jnlp downloads my application ...

Remove boilerplate from db code

It seems that every time I want to perform a db query, I have to write the following: Connection conn = null; Statement stmt = null; ResultSet rset = null; try { conn = dataSource.getConnection(); stmt = conn.prepareStatement(sql); // ...set stmt params rset = stmt.executeQuery(); while(rset.next()) { // Do ...

How do you do an extended insert using JDBC without building strings?

I've got an application that parses log files and inserts a huge amount of data into database. It's written in Java and talks to a MySQL database over JDBC. I've experimented with different ways to insert the data to find the fastest for my particular use case. The one that currently seems to be the best performer is to issue an extende...

Dynamically access multiple databases?

My question is very related to this one: http://stackoverflow.com/questions/932625/multiple-dynamic-data-sources-for-a-servlet-context. However I haven’t found a proper solution just yet and would like to ask it again. I have a little JSF application that talks to a MS SQL Server via JDBC. Tomcat is used as the web container. The applic...

Find jdbc driver in Maven repository

Hi, I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14. In MVNrepository site the dependency to put in the POM is: <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc14</artifactId> <version>10.2.0.3.0</version> </dependency> of course this does't work as it is not in the c...

Is there a jdbc driver for SQL Server that can search for database instances on network?

Is there a jdbc driver for SQL Server that can search for database instances on network? Just wanting to emulate "OSQL -L" from the JDBC driver. Dont want to have to call OSQL from JNI or something. I also don't want to have to write my own code for scanning a UDP port. I want my Java application to be able to search for live SQL S...

Is there a way to set mysql variables using the JDBC Connector?

In Java, of course. I need to enable "force", but I have no idea how. I'm sure it might go somewhere in the URL, but I've tried a bunch of different things and looked for a bit on Google, to no avail. Thanks! ...

Snippet to create a file from the contents of a blob in Java

I have some files stored in a database blob column in Oracle 9. I would like to have those files stored in the file system. This should be pretty easy, but I don't find the right snipped. How can I do this in java? PreparedStatement ptmst = ... ResutlSet rs = pstmt.executeQuer(); rs.getBlob(); // mistery FileOutputStream out...

How can I connect to an Oracle database from Ant using the tnsname?

I am looking for something similar to the Ant sql task but that will accept a JDBC url of the format: jdbc:oracle:thin:@TNS_NAME One possible approach seems to be to write my own Ant task that uses an OracleDataSource to create the Connection, but is there a way to do this straight in Ant? EDIT: Thanks for the responses so far g...

NLS_LANG setting for JDBC thin driver?

I am using the thin Oracle JDBC driver ver 10.2.0 (ojdbc14.jar). I would like to configure its NLS_LANG setting manually. Is there a way? Currently it fetches this setting from the VM variable user.language (which is set automatically by setting the current locale, or on startup from the system environment). This is a problem when the ...

Fastest way to iterate through large table using JDBC

I'm trying to create a java program to cleanup and merge rows in my table. The table is large, about 500k rows and my current solution is running very slowly. The first thing I want to do is simply get an in-memory array of objects representing all the rows of my table. Here is what I'm doing: pick an increment of say 1000 rows at a ti...

What is the best database to use with a java program?

I've been struggling to get a Java program to connect to MS SQL Server, and I'm starting to wonder if MySQL would be a better choice for my (learning) project. Sun's tutorials refer to Java DB, but I've never heard of that in any other context, so it seems not the most useful database to learn about. I appreciate any insight into the m...