jdbc

Transaction Control across multiple JVMs

I have what seems to be a standard java problem: multiple database transactions, in Oracle, that need to all be committed or none. This is complicated by the fact that each process is in a seperate JVM. The modules are connected by JMS queues in a pipeline configuration. The idea is that a series of messages can be passed through the p...

JDBC-appender Log4j [RESOLVED]

Hey folks. Re-thinked IDEA! So, I've been thinking over the weekend and couldn't let this one go. I've decided to re-try the idea of getting log4j to work. I've been doing some coding and think I got it to work. Except, I do not really understand how to insert into the logger. I've created an JDBC-appender and the SQL looks like this:...

JSP: execution non-English chars in mysql query

I wrote a JSP code that needs to run some mysql INSERT queries that contains non-English chars (Persian). I run two types of queries first one is static application installation queries and second one is user inputs. After execution of both of queries non-English chars are imported as "?" as I check them in application itself and phpMyAd...

Hibernate cannot open connection

Hi all, I'm having trouble with hibernate not able to open a connection. I have a DAO: public class MyDao extends HibernateDaoSupport { DataSource dataSource; public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; } public MyPOJO findByQuery(int hour) { Query query = th...

jexcel - transpose question

I am trying to work with JExcel API and had the following question. I have queried my database tables for 3 columns: id, time, value. I am adding them into different arrays as objects. I want to output them into an excel sheet as follows: id 9:10 9:11 9:12 1 value value value 2 value value value 3 va...

MySQL timestamp to Java date conversion

How can I convert time in unix timestamp to normal time? ...

Last batch from prepared statment won't get written unless I close the connection.

I'm doing a small project including a connection to sqlite. I write to two tables with a one to many relation. The last batch to the second table won't get written unless I explicitly closes the connection. I find it strange since the database is in auto-commit mode (i.e. connection.commit() throws an error). I would like to keep the c...

mysql jdbc driver does not support delimiters in triggers with multiple statements

i've got some code that is triggering a syntax error because of some misplaced semicolons. if this was running on the command line, i'd solve this with a delimiter. unfortunately, the jdbc4 driver doesn't seem to recognize delimiters. anyway to get this to run? delimiter | CREATE TRIGGER obs_update BEFORE UPDATE ON obs FOR EACH ROW BEGI...

Connection Time Out JDBC-MySQL

I have a Java application running Win 7 connecting to MySQL on the same host. Eclipse IDE shows the following error every time after 8-10mins. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at com.mysql.jdbc.SQLError.createCommunicationsException...

How to configure Tomcat 6.0 with MySQL

Can one explain little more about how to configure Tomcat with MySQL? Where to place mysql-connector-java-5.1.13-bin in Tomcat directory? Should I place it under Tomcat 6.0\webapps\myapp\WEB-INF\lib? Do I need to confirgure context.xml or server.xml files? Should I write web.xml file and need to place under Tomcat 6.0\webapps\myapp\WEB...

Unable to connect MYSQL database using JSP and TOMCAT

I am unable to connect database “test” created in mySQL using Java Server Pages (JSP) & Tomcat. I am getting the error message "Unable to connect to database". I am using following software specifications Tomcat 6.0 jdk1.6.0_21 mySQL 5.1.49 mysql-connector-java-5.1.13-bin I have configured following environment variables as follow ...

executeQuery does not timeout

I am trying to use prepared statements which operate on a database located quite far away, there is considerable lag and unreliability involved in the network connection used to access this database. Downtimes of up to a minute are common. The problem is that in case of such a failure, if my program tries to execute any prepared statemen...

Getting Database connection in pure JPA setup

We have a JPA application (using hibernate) and we need to pass a call to a legacy reporting tool that needs a JDBC database connection as a parameter. Is there a simple way to get access to the JDBC connection hibernate has setup? ...

grouping data in java

hi is there someway we can group similar data in java? i want to group all the data with same id and print it out. i am querying for the data using jdbc and was searching for a library i could use for this. any idea? thanks ...

Is there a Java API for comparing Database Schemas

I'd like to compare if tables columns including datatypes and length/precision. indexes and their columns constraints in two database schemas are identical. Is there anything like this available? Maybe from one of the database migration managing tools? ...

mysql query for timezone conversion

hi, is there a way to convert from unix timestamp to GMT in mysql while running the query itself?? My query is as follows: SELECT r.name , r.network , r.namestring , i.name , i.description , r.rid , i.id , d.unixtime // this is the unix time i am asking to print , d.ifInOctets FROM range AS r INNER JO...

Oracle connection error using Tomcat

I am using Eclipse Galileo and Tomcat 6.0. I am getting an error like this: 2010-08-17 00:09:42,684,JDBCExceptionReporter,WARN,,SQL Error: 0, SQLState: null 2010-08-17 00:09:42,684,JDBCExceptionReporter,ERROR,,Cannot create PoolableConnectionFactory (ORA-01033: ORACLE initialization or shutdown in progress ) 2010-08-17 00:09:42,684,Sett...

How can I call an Oracle stored procedure with JDBC/Spring where some of the parameter type are user defined?

I'm trying to call an Oracle stored procedure from my Java program. I'm using JDBC and Spring's StoredProcedure. A couple of the parameters are user defined types and I need to know how to pass them in. In particular what type should I specify in the parameter map (i.e. which of java.sql.Types.*)? And what Java type should I use? Th...

java.sql.SQLException: Exhausted Resultset

I get the error java.sql.SQLException: Exhausted ResultSet to run a query against an Oracle database. The connection is via a connection pool defined in Websphere. The code executed is as follows: if (rs! = null) ( while (rs.next ()) ( count = rs.getInt (1); ) )...

Derby INSERT SELECT null pointer exception

I'm writing a Java application that's working with Apache Derby via JDBC. I'm having problems with the code in the following snippet: byte md5[] = md5sum(file); PreparedStatement s = con.prepareStatement("INSERT INTO input_files (job_ID, hash) SELECT job_id, ? FROM job WHERE job_name = ?"); s.setBytes(1, md5); s.setString(2, jobName); ...