jdbc

What MS SQL Server types map to Types.VARCHAR

I'm working on a statement scanner for our updater (looking for statements that will cause problems with synchronized data) and I need to know which TSQL data types get resolved as Types.VARCHAR and which ones resolve to Types.LONGVARCHAR when you invoke DatabaseMetaData.getColumns()? ...

How to change default nls_date_format for oracle jdbc client

I have defined the global nls_date_format on Oracle 10.2 XE as follows: alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile; When connecting on Windows, the clients override it with session specific format, so I need to run this line at the beginning of every session: alter session set nls_date_format='YYYY-MM-DD HH...

Using JDBC, how can I substitute multiple IDs into "DELETE FROM T WHERE id IN (?)"

I have some code that produces a set of primary key values that I want to delete from a database table. long[] keysToDelete = { 0, 1, 2, 3 }; and I'd like to use a PreparedStatement to execute the equivalent of DELETE FROM MyTable WHERE myPrimaryKey IN (0, 1, 2, 3); Any idea how? ...

Hiberate problems, jdbc IDENTITY_INSERT is set to OFF

I am getting JDBC error when I attempt a commit through hibernate to SQL Server Cannot insert explicit value for identity column in table 'Report' when IDENTITY_INSERT is set to OFF I am using mappings generated by netbeans that contain, <class name="orm.generated.Report" table="Report" schema="dbo" catalog="DatabaseName"> <id...

Creating package-level associative array in java

Is it possible to create a java representation of a package-level oracle associative array. For example, given the following: CREATE OR REPLACE PACKAGE MyPackage AS TYPE t_numbers IS TABLE OF NUMBER INDEX BY PLS_INTEGER; I find I cannot write the following java: ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("M...

How can I find out how many rows a MySQL query returns in Java?

How can I find out how many rows a MySQL query returns in Java? ...

How do I check to see if a column name exists in a CachedRowSet?

I am querying data from views that are subject to change. I need to know if the column exists before I do a crs.get*X*().I have found that I can query the metadata like this to see if a column exist before I request the data from it. ResultSetMetaData meta = crs.getMetaData(); int numCol = meta.getColumnCount(); for (int i = 1; i < nu...

Weird JDBC executeQuery exception

I have the following code: public Object RunQuery(String query) throws Exception{ System.out.println("Trying to run query"); Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); System.out.println("Got Statement"); rs = stmt.executeQuery(query); System.out.prin...

JDBC Wrapper tutorial - is it still relevant?

This article from IBM about a JDBC wrapper seems good and I'm tempted to use it: http://www.ibm.com/developerworks/java/library/j-jdbcwrap/index.html but it its dated 2001 - is it still relevant to today's best practices or has this been superseded by something else better? Your opinions are much appreciated. ...

Spring JdbcTemplate and Threading

Is it safe to fork off a Thread to execute an insert using a JdbcTemplate in Swing. It's a logging event and as much as possible I don't want it to affect perceived performance. ...

How to connect to database from Jython

I cannot connect to database from my Jython program. Pure Java programs can connect, and I can connect to db from Jython but only using JDBC-ODBC bridge: "sun.jdbc.odbc.JdbcOdbcDriver". If I use native JDBC driver my program fails with "driver not found" exception. Code: import sys from com.ziclix.python.sql import zxJDBC connection1 ...

How many JDBC connections in Java ?

I have a Java program consisting of about 15 methods. And, these methods get invoked very frequently during the exeuction of the program. At the moment, I am creating a new connection in every method and invoking statements on them (Database is setup on another machine on the network). What I would like to know is: Should I create only...

Consistent method of inserting TEXT column to Informix database using JDBC and ODBC

I have problem when I try insert some data to Informix TEXT column via JDBC. In ODBC I can simply run SQL like this: INSERT INTO test_table (text_column) VALUES ('insert') but this do not work in JDBC and I got error: 617: A blob data type must be supplied within this context. I searched for such problem and found messages from 200...

Is it possible to make a JDBC connection through SSIS?

I've never used a JDBC connection before, and am familiar with only ODBC connections. We have a vendor who will only support JDBC. They consider ODBC 'Open Source', and therefore do not support connections to their DB through an ODBC connection. Does anyone know if it is possible to create an SSIS connection via JDBC? I am not getting an...

JDBC Connection Issue

I have create a getDBConnection method in my Java application. This returns a connection object, and hence I haven't closed this connection in this method itself. Now, I am invoking this method from various methods in my application at regular intervals, and closing them inside a try - finally block. I thought this should free up the c...

Building a data layer using Spring JdbcTemplate

Do you know of any resources that describe building a data access layer using Spring's JdbcTemplate classes? I'm looking for something beyond the basics described in the Spring framework documentation. ...

Is jdbc by itself compatible with mysql.

I'd like to know if jdbc by itself is compatible with mysql or do I have to intsall something extra? I was told it is not compatible and that I'd have to use a different database. ...

Is DBCP (Apache Commons Database Connection Pooling) still relevant?

The JDBC 3.0 spec talks about Connection (and Prepared Statement) pooling. We have several standalone Java programs (i.e. we are not using an application server) that have been using DBCP to provide connection pooling. Should we continue to use DBCP, or can we take advantage of the JDBC-provided pooling and get rid of DBCP? We are usi...

Lazy Loading DTO fields in Spring

I have a project that is using Spring and is broken down into a couple dozen DAOs and associated DTOs. I'm using JdbcTemplate, but not much else, as it's exactly the level of abstraction I'm happy with. I'm currently performing lazy loading on my DTOs by placing some rather hairy code in their getters. Basic boilerplate logic is: 1....

What happens if I don't include a db driver when using JDBC?

I'm new to java development, and was happy to see how much easier the database implementation was when it comes to supporting several platforms, compared to the php environment I'm used to. There is, however, one thing I'm confused about - I read everywhere I have to do a runtime-include of the database driver I want to use, ie: Class....