jdbc

UNIX socket implementation for Java?

I realize that since UNIX sockets are platform-specific, there has to be some non-Java code involved. Specifically, we're interested in using JDBC to connect to a MySQL instance which only has UNIX domain sockets enabled. It doesn't look like this is supported, but from what I've read it should be at least possible to write a SocketF...

Delete all tables in Derby DB

How do i delete all the tables in the schema on Apache Derby DB using JDBC? ...

Error connecting to oracle. Getting an UnsatisfiedLinkError for the method t2cGetCharSet

Hi, I am running a series of JUnits using Apache ANT using JDK 1.5. All JUnits that use an Oracle JDBC driver give the UnsatisfiedLinkError shown below. What native library is it looking for and how do I solve this? What should the PATH variable contain? oracle/jdbc/driver/T2CConnection.t2cGetCharSet([CI[CI[CI[CII[SLoracle/jdbc/drive...

How can I expose a C ODBC connection to a JVM using JNI?

I'm embedding a JRE in an existing C application using the invocation API, and I'd like to be able to use JDBC to work with the database in that code. This application is a transaction processing application, and the database transaction is managed by code in the C portion of the application, and the java code must run within that trans...

How do you determine if a JDBC Connection was retrieved from a JTA enabled DataSource or straight JDBC?

I'm using a vendor API to obtain a JDBC connection to the application's database. The API works when running in the application server or when running in a stand-alone mode. I want to run a series of SQL statements in a single transaction. I'm fine with them occurring in the context of the JTA transaction if it exists. However, if it doe...

How do I use oracle.jdbc.driver.OracleLog?

I am receiving an error from the Oracle JDBC driver (ojdbc14_g.jar) when trying to obtain a connection to a 10g database. The driver has an oracle.jdbc.driver.OracleLog class which could help but the Oracle documentation is unclear how best to use it. Has anyone had any success using this class? If so, some guidance on its use would be a...

What options are available for connecting to a Microsoft SQL Server database from an Oracle database?

At the moment I pull data from remote MS SQL Server databases using custom-built JDBC connectors. This works fine but doesn't feel like the way to do it. I feel I should be able to put a JDBC connection string into tnsnames on the server and have it "just work". I've looked around a little for this functionality but it doesn't seem to b...

ResultSet: Retrieving column values by index versus retrieving by label

When using JDBC, I often come across constructs like ResultSet rs = ps.executeQuery(); while (rs.next()) { int id = rs.getInt(1); // Some other actions } I asked myself (and authors of code too) why not to use labels for retrieving column values: int id = rs.getInt("CUSTOMER_ID"); The best explanation I've heard is some...

How should I configure Jetty 7 pre3 to use oracle JDBC source?

All stuff is running under Windows XP Pro SP2/32-bit. I have downloaded Jetty 7 pre3 from http://dist.codehaus.org/jetty/jetty-7.0.0-prereleases/jetty-7.0.0pre3/jetty-assembly-7.0.0pre3.zip>dist.codehaus.org. I have extracted jetty to C:\jetty-7.0.0pre3\ (so I have C:\jetty-7.0.0pre3\bin\ and other dirs) I have put my webapp into C:\jet...

What JDBC tools do you use for synchronization of data sources?

Hello. I'm hoping to find out what tools folks use to synchronize data between databases. I'm looking for a JDBC solution that can be used as a command-line tool. There used to be a tool called Sync4J that used the SyncML framework but this seems to have fallen by the wayside. ...

Java: How do I get the size of a java.sql.ResultSet?

Shouldn't this be a pretty straightforward operation? However, I there is no size() or length() method. ...

Why isn't querying a JDBC-compliant database from Oracle as easy as pie?

Ok, so it's almost as easy as pie already. But it really should be as easier than it is. I think I should be able to connect to another database just by putting a JDBC connection string into TNSNAMES. Every database vendor has a type-4 JDBC driver and there's usually a good, free alternative. With Oracle being such keen Java fans, and ...

Postgres JDBC connection in Eclipse Help

Hi Everyone, I'm trying to get a postgres jdbc connection working in eclipse. It would be nice to use the Data Source Explorer, but for now I'm just trying to get a basic connection. What I have done so far is download the postgres JDBC connector. I then tried two different things. First, Preferences-> Data Management, I tried to add th...

Primary key from inserted row jdbc?

Is there a cross database platform way to get the primary key of the record you have just inserted? I noted that this answer says that you can get it by Calling SELECT LAST_INSERT_ID() and I think that you can call SELECT @@IDENTITY AS 'Identity'; is there a common way to do this accross databases in jdbc? If not how would you suggest ...

Reusing a resultMap for different column names

Is there a way of reusing the same resultMap multiple times in a single query. For example, suppose I have a "foo" resultMap: <resultMap id="foo" class="Foo"> <result property="Bar" column="bar" /> </resultMap> Is there a way to define another resultMap that reuses the above for different columns? Something like... <resultMap id="...

Connection to Oracle without a username or password

Oracle has this concept of allowing database users to be identified by the operating system user who is running the program that is connecting to Oracle. See here. This allows you to do, as that user on a unix machine for example, a command such as: sqlplus / I am attempting to write a Java program for Oracle 10.2 which connects with...

Update more than one row atomically

I need to execute a select and then update some of the rows in the ResultSet in an atomic way. The code I am using looks like (simplified): stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = stmt.executeQuery("SELECT ..."); while (rs.next()) { if (conditions_to_update) { rs.update...

Problems with globalization when using Oracle collections with thin JDBC

To summarise the issue: Retrieving strings in Java 1.5 (JDBC) works fine when the DB encoding is Western ISO 8859-2 When switching to an Eastern European ISO (e.g. ISO 8859-5), all the normal JDBC string conversions work, except the ones involving Oracle collections, e.g. nested tables of objects. Instead of proper strings, even simple...

getResultSet from Spring-JDBC

Hi, I'm using Spring's support for JDBC. I'd like to use JdbcTemplate (or SimpleJdbcTemplate) to execute a query and obtain the result as an instance of ResultSet. The only way that I can see of achieving this is using: String sql = "select * from...."; SqlRowSet results = jdbcTemplate.queryForRowSet(sql); ((ResultSetWrappingSqlRowSet...

What's the best way to get the last inserted id using sqlite from Java?

What's the best way to get the last inserted id using sqlite from Java? Google is giving me different answers--some say select the last-insert-rowid; others say call statement.getGeneratedKeys(). What's the best route to take? (I just want to return the id, not use it for other inserts or anything.) ...