RE: Chat program using derby

2008-02-19 Thread Jim Newsham
> when i run both the programs:i get the following exception:mhjfdshmnjh > java.sql.SQLTransactionRollbackException: A lock could not be obtained > within the time requested The problem is that database writes in one client acquire row or table locks, which prevent the other client from accessing

Re: Chat program using derby

2008-02-19 Thread Waqar Hassan
> int period = 2000; // repeat every 5 seconds > Timer timer = new Timer(); > System.out.println(" Timer set"); > > DBClass dbobject2=new DBClass(); > final Connection conn2=dbobject2.createConnection("ChatDB1"); > conn2.setAutoCommit(false); > stmt = conn2.createStatement(); > //dbclass db=new dbclass(); > > timer.scheduleAtFixedRate(new TimerTask () > { > public void run() > { > try > { > PreparedStatement pstmt=conn2.prepareStatement("select * from bobtable > where > TID=0"); > //pstmt.setInt(1,id); > > rs=pstmt.executeQuery(); > //stmt.executeUpdate("lock table bobtable in exclusive mode"); > > stmt.executeUpdate("Update bobtable set TID=1 where TID=0"); > //rs1=pstmt.executeQuery(); > > > while(rs.next()) > { > String str=rs.getString(2); > int str2=rs.getInt(1); > System.out.println(str2+" "+str); > //text1.setText(str2+" "+str); > } > > > } > > catch ( Exception e ) {System.out.println("mhjfdshmnjh "+e);} > > } > }, initialDelay, period); > } > } > > when i run both the programs:i get the following exception:mhjfdshmnjh > java.sql.SQLTransactionRollbackException: A lock could not be obtained > within the time requested > > please help me. > > regards. > -- > View this message in context: > http://www.nabble.com/Chat-program-using-derby-tp15561400p15561400.html > Sent from the Apache Derby Users mailing list archive at Nabble.com. > > -- ! ! ! WACK ! ! !

Re: Chat program using derby

2008-02-19 Thread Waqar Hassan
uled"); > int initialDelay = 1; // start after 30 seconds > int period = 2000; // repeat every 5 seconds > Timer timer = new Timer(); > System.out.println(" Timer set"); > > DBClass dbobject2=new DBClass(); > final Connection conn2=dbobject2.createConnection("C

Chat program using derby

2008-02-19 Thread musky
TID=0"); //rs1=pstmt.executeQuery(); while(rs.next()) { String str=rs.getString(2); int str2=rs.getInt(1); System.out.println(str2+" "+str); //text1.setText(str2+" "+str); } } cat