jdbc

How to create a database deadlock using jdbc and JUNIT

I am trying to create a database deadlock and I am using JUnit. I have two concurrent tests running which are both updating the same row in a table over and over again in a loop. My idea is that you update say row A in Table A and then row B in Table B over and over again in one test. Then at the same time you update row B table B and...

How to save Map objects in Java to MySQL database

I have Java Map (out of Strings and Ints) objects that I want to save to a database. Is there a standard way to go about this task? Is there a way to compress the Map to take less space on the harddrive? ...

JDBC Null pointer Exception thrown

Hi I'm getting nullpointerexception at rs.next() or rs.getString(1) it is really weird that sometimes rs.next() works fine and it throws nullpointerexception at rs.getString("PRODUCTCODE"),sometimes it throws npe at rs.getString("PRODDATE") i dont understand why rs.getString() thows npe while rs.next() works fine Here is my code { Res...

AbstractMethodError when invoking createArrayOf, with postgresql 8.4 jdbc4 and JBoss 5.1GA

Hi, when using this method public List<Field> getFieldWithoutId(List<Integer> idSections) throws Exception { try { Connection conn = this.getConnection(); Array arraySections = conn.createArrayOf("int4", idSections.toArray()); this.log.info("Recupero field"); List<Field> fields = this.getJdbcTemplate...

Reading greek text from jdbc / SQL Server 2005 and displaying it with a servlet

Well, the subject says it all but I will explain a little further. I have a database in MS SQL server 2005 that contains greek text. I have created a servlet that connects to that database using net.sourceforge.jtds.jdbc.Driver and receive some data with the following commands: Connection con = DriverManager.getConnection(connectionUr...

How to avoid this very heavy query that slows down the application?

Hi, We have a web application running in a production enviroment and at some point the client complained about how slow the application got. When we checked what was going on with the application and the database we discover this "precious" query that was being executed by several users at the same time (thus inflicting an extremely hi...

Getting a connection from a Sybase datasource in WAS 6.1 fails with message "User name property missing in DriverManager.getConnection"

I have a standalone application that needs to connect to a Sybase database via a datasource, I'm trying to connect using getConnection() and get the connection from this Sybase datasource which is hosted in WAS 6.1, sadly I'm getting an error JZ004 -> Sybase(R) jConnect for JDBC(TM) Programmer's Reference: SQL Exception and Warning Messa...

Store HTML into MySQL database

I'm trying to store a String which contains HTML in a MySQL database using Longtext data type. But it always says "You have an error in your SQL syntax". I tried to store a normal String and it works. Update: This is the query: st.executeUpdate("insert into website(URL,phishing,source_code,active) values('" + URL + "','" + phishingSt...

servlets and resource file

Is it possible to write database methods in properties file, like some database queries and can be accessed using servlets which may reduce the code? ...

SQL (Java, h2): What's the best way to retrieve the unique ID of the single item I just inserted into my database?

My current method is this: SELECT TOP 1 ID FROM DATAENTRY ORDER BY ID DESC This assumes the latest inserted item always has the highest unique ID (primary key, autoincrementing). Something smells wrong here. Alternatives? ...

JDBC connection for a background thread being closed accessing in Websphere

Hi, I have an application running in Websphere Portal Server inside of Websphere Application Server 6.0 (WAS). In this application for one particular functionality that takes a long time to complete, I am firing a new thread that performs this action. This new thread opens a new Session from Hibernate and starts performing DB transactio...

Configure Hibernate to obtain a fresh connection from a connection pool.

How do I configure Hibernate so that each time I call sessionFactory.openSession() it connects with a new connection from the connection pool? The connection pool is managed by Websphere Application Server and is a JDBC Data Source. Thanks ...

Binding a null variable in a PreparedStatement

I swear this used to work, but it's not in this case. I'm trying to match col1, col2 and col3, even if one or more of them is null. I know that in some languages I've had to resort to circumlocutions like ((? is null AND col1 is null) OR col1 = ?). Is that required here? PreparedStatement selStmt = getConn().prepareStatement(...

JDBC profiling tools

We need to profile the JDBC operations of several web applications, number of queries, time spent, rows returned, ... Have you used any free/commercial JDBC profiling tool? What are your experiences? Thank you. ...

Crystal reports - connection to JDBC failed

Hello, I am trying to make a connection to JDBC(JNDI) in Crystal Reports and I get the following error : Invalid Argument provided. Details: Java Server startup failure. Please verify the PATH (JDK), CLASSPATH and IORFileLocation properties in the CRConfig.xml file. In addition, please verify you are using JDK 1.4. I am using th...

jdbc nested transactions

What is the behaviour of nested transactions. I am using java + jdbc ? Eg: tx1.begin do stuff1 tx2.begin do stuff2 tx2.commit do stuff1.1 tx1.rollback tx2 is basically inside another function. Will the results from tx2 be persisted ? In case behaviour is db specific, what is it in case of Sql server 2005 ? ...

connecting to MySQL using JDBC in eclipse

Hello, So I want to create a JDBC connection to MySQL server that is installed on my pc, here are the steps, I installed MySQL with the username and password "root", downloaded mysql-connector-java and from theere I coped the JAR "mysql-connector-java-5.1.12-bin" to "C:\Sun\SDK\jdk\jre\lib\ext", I then added it as an external JAR in my ...

Installer package for program that uses JDBC to connect to MySQL....

I have an installer wizard thing called 'install creator'. I want to include my mySQL database into the installer or find another way that the user, upon installation, can just use my database. Prob is-not everyone has MySQL installed on the computer and even then, the user doesn't know the name of the database or my password. Somehow th...

Calling an Oracle PL/SQL procedure with Custom Object return types from 0jdbc6 JDBCthin drivers

I'm writing some JDBC code which calls a Oracle 11g PL/SQL procdedure which has a Custom Object return type. Whenever I try an register my return types, I get either ORA-03115 or PLS-00306 as an error when the statement is executed depending on the type I set. An example is below: PLSQL Code: Procedure GetDataSummary (p_my_key IN ...

How to get only the first row from a java.sql.ResultSet?

I have a ResultSet object containing all the rows returned from an sql query. I want to be able to (in the java code, NOT force it in the SQL) to be able to take a ResultSet and transform it so that it only contains 1 (the first) row. What would be the way to acheive this? Also, is there another appropriate class (somewhere in java.sq...