Problems with JDBC autoReconnect and wait_timeout

2003-03-11 Thread Emma Wansbrough
Hi,
I am having major problems with persistant database connections on a 
resident process in java.

My database connection url looks like this:

jdbc:mysql://balti/log?autoReconnect=true&user=root&password=pineapple

But it does not appear to be reconnecting because if I go into 
/etc/my.cnf and set variable wait_timout to be 3 seconds or so I get the 
usual java Communication Link exception, meaning the the connection has 
gone idle and no attempt has been made to reconnect.
the version I am using is mysql-connector-java-3.0.6-stable.

Another curious factor is that the wait_timout applies to my java 
connections but not when I run mysql as root.

Why is this?

The mysql version is mysql-max-4.0.9-gamma-pc-linux-i686

The most disturbing thing is that the url autoReconnect seems to not be 
working.
Emma.

-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


JDBC Driver Bug, does not appear to support auto commit off-selections not detected in while loop if new insertions

2003-02-28 Thread Emma Wansbrough

My code works fine with autcommit on..however it does not support
autocommit off. This is quite a big bug, or I have missed something out.
Please let me know as I it would be of great interest to me if I was
mistaken or correct and you will consider fixing it.

If I switch off auto commit and select rows from a database table in a
loop when I enter new values to the table it will not find them unless I
specifically commit after every select statement. 
Surely this is select for update( with InnoDB) ? not just an ordinary
select! 

This presents awkwardness with multi-threading and I have to do
work-around such as not committing if a flag is set which should not be
necessary.
I have tried afew versions of you JDBC driver and it always performs the
same.

You should be able to make simple selects without having to commit, the
c api does exactly that!

Here is some example java code to prove point:

import java.sql.*;
import java.util.*;

public class TestSQL
{

static Connection conn;
public static Connection getConnection()
{
try
{
if (conn == null)
{
 
Class.forName("com.mysql.jdbc.Driver").newInstance();
  conn =
DriverManager.getConnection("jdbc:mysql://localhost/operations?user=root
&password=pineapple");
System.out.println("new connection
created!!");
}
  conn.setAutoCommit(false);
return conn;
}
catch (Exception e)
{
System.out.println ("Connect Exception"+e);
return null;
}
}

//  Main Method for Testing only 
public static void main(String args[]) throws Exception
{
Connection conn=  TestSQL.getConnection();
while(true)
{
ArrayList results = new ArrayList();
Statement stmt = conn.createStatement();
//ResultSet rs = stmt.executeQuery("SELECT
feed_id from sotf_feed_event");  
PreparedStatement ps =
conn.prepareStatement("SELECT feed_id from sotf_feed_event");
ResultSet rs = ps.executeQuery();
ResultSetMetaData meta = rs.getMetaData();
int count;
   
count = meta.getColumnCount();
while (rs.next())
{
Hashtable cols= new Hashtable(count);
int i;
for (i=0;i0)
{   
System.out.println("got something");
}
else
{
System.out.println("nothing");
}
// if I dont put this in it never finds a newly
added row
//conn.commit();
Thread.sleep(5000);
rs = null;
}
}
}

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php