jdbc

Multiple insert in a loop in jdbc

while (tokens.hasMoreTokens()) { keyword = tokens.nextToken(); System.out.println("File= "+fileid+" Keyword=" + keyword); stmt.executeUpdate( "INSERT into TEXTVALUEINVERTEDINDEX " + "(FILEID, KEYWORD) values ('" + fileid + "', '" + keyword + "')" ); } This is the loop in which I'm updating the row...

Can commits be automatically collected into a batch?

Is there a way to automatically put multiple updates into batches? For example, transform this program: PreparedStatement prepStmt = con.prepareStatement("UPDATE DEPT SET MGRNO=? WHERE DEPTNO=?"); prepStmt.setString(1,mgrnum1); prepStmt.setString(2,deptnum1); prepStmt.executeUpdate(); ...

Parse SQL via Oracle's JDBC driver

I'd like to test whether given SQL statement is syntactically and semantically valid (ie. no syntax errors and no field misspellings). For most databases Connection.prepareStatement and PreparedStatement.getMetaData would do the trick (no exception == good query). Unfortunately Oracle's newest driver only parses like this only SELECT qu...

How to diagnose performance problems with SQL Server Views and JDBC

I have a view defined in SQL server 2008 that joins 4 tables together. Executing this view in SQL Server Management Studio takes roughly 3 seconds to run and returns about 45,000 records. My application is written in Java using hibernate to simply do a "from MyViewObject" query in HQL. When this is run, the execution time is consisten...

Hashed passwords updated through JDBC become corrupt. (More of encoding problem than hashing)

I've tried the following with MySQL UTF-8 and Latin-1, to no avail. I hash my passwords (in this case toSecurify) using SHA-1 like so: if(toSecurify == null) { throw new Exception("toSecurifyString must not be null"); } try { MessageDigest messageDigest = MessageDigest.getInstance("SHA-1"); byte[] sha1HashBytes = new by...

Remove padding added by legacy DB2 databases on query results

I have the following setup. 'Apps/Reports' <---------> 'DB2 Connect' <------------> 'Legacy DB2 on AS400' `Hibernate` `native calls` When data is retrieved from by the application, it will be padded with extra spaces if the length is less that the column length. Of note when running a query, if the WHERE c...

JDBC connect string and Oracle synonyms

Hi, we have a Java program connecting via JDBC thin client to an Oracle 10g database. Everything was working fine, but now the DBA wants us to connect with a different username/password, which is supposed to have access to the same tables using public synonyms. Unfortunately the Java program no longer sees the tables (see error below wh...

Mysterious SQL blocking my stored procedure from executing on ORACLE

I am trying to run a procedure on ORACLE with the thin jdbc client and c3p0. here's the code that's supposed to run: Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("I_NODE_ID", nodeId); paramMap.put("I_PARENT_ID", parentId); paramMap.put("I_STRUCTURE_ID", structureId); ...

How to use MySQL JDBC driver in an SBT Scala broject?

When I run my project for the first time during an SBT session, it throws the following exception when trying to access a MySQL database: java.lang.NoClassDefFoundError: scala/Ordered When I run it again (and any time after it, during the same SBT session), it throws a different one: java.sql.SQLException: No suitable driver fo...

JAVA JDBC Jtds problem to establish a conection

guys i'm with a Hell Problem!! :| i want to make a access to my sql database than is placed in ASUS\MSSQLSERVER1 and database names "Test" with access to user teste with password teste in java code i coded this: @Test public void TesteTemp() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundExceptio...

Tomcat 6 connection pool goes wacky when CMS GC is used

We recently changed to the CMS garbage collector on our server (XX:+UseConcMarkSweepGC) which worked fine in tests. When we went to production, things were OK for the first few hours, but then we suddenly began to see the dreaded: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idl...

JDBC + PL/SQL = Is it so simple, or is there a catch?

Hello, I am planning to execute Oracle PL\SQL blocks via JDBC (can't test it yet, question of few days). Is there anything I should know? Does everything work as it used to with plain SQL? I mean: ResultSet rs = st.executeQuery("DECLARE BEGIN NULL; END;"); Or will I need some custom classes? I'd like to keep it as much simple as pos...

Difference between JTA, JPA and Plain JDBC in hibernate

Hi, Can anyone tell me what is the difference between JTA, JPA, and Plain JDBC in terms of hibernate? I have been asked continuously this question and I fumble while giving the answer. Best Regards, Aashutosh ...

Is this error related to the OS or the database ??

I have a java programs that gives me an error after working fine for a few hours ... these programs used to work fine on our earlier server which had windows server 2003 now we have upgraded to windows server 2008 with a higher configuration and newly installed SQL Server .Is there any db setting that i'm missing or is there any OS setti...

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Can't call rollback when autocommit=true

hi All, Im using Jboss5.0 with mysql in my application. and there will be lot of concurrent actions and DB contains considerably lot of records. this error is coming frequently.. every now and then. com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Can't call rollback when autocommit=true at com.mysql.jdbc.SQLErro...

Accessing JNDI from within Eclipse OSGI bundle, hosted in WebSphere App Server

Hi, I have a problem accessing JNDI resources from within an OSGI bundle, hosted in WebSphere Application Server (WAS) using a servlet bridge. It is failing on creating the JNDI initial context. My code is: Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory...

PostgreSQL: Which connectivity uses psql tool of PostgreSQL

Does anybody know how psql accesses PostgreSQL database? What it uses odbc, jdbc or some native database library? ...

Which OJDBC Driver for Java 6?

We're currently using ojdbc14.jar, should we be using ojdbc6.jar ? Update: Oracle 10g being used ...

Whats the difference between using out parameters vs. result fetching by column in stored procedures that return a single result called through JDBC?

I know for more than one result, you don't have much choice for using out parameters, but I'm wondering whats the difference between the following 2 cases where there's one out parameter. Say I have two stored procedures: CREATE PROCEDURE no_out_params(IN foo INT) BEGIN SELECT foo + 1 as result; END and CREATE PROCDURE with_out_pa...

import the oracle dump programatically through java??

is there a way to import the oracle dump through java program?? If yes, How?? Thanks in advance ...