Forums Register Login

SCROLL SENSITIVE

+Pie Number of slices to send: Send
Hi Everybody,

I am using a scrollable sensitive result set. What I know about it, if the Data base value has been changed in the mean time when the JDBC application is traversing the result set, the effect will be displayed in the result set. But surprisingly I am not getting the result. Here is the code.

import java.sql.Connection;
//import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
*
* @author mc11
*
*/
public class TestScrolableSens
{
private static Connection connection = null;
private static Statement statement = null;
private static ResultSet rs = null;

public static void main(String args[])
{
String sql = "SELECT * FROM EMP";
try
{
connection = JDBCLoader.getConnection("dbc:oracle:thin:@off2:1521:VELOZ","scott","tiger");
statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = statement.executeQuery(sql);
while(rs.next())
{
Thread.sleep(15000);
String empNo = rs.getString("EMPNO");
int salary = rs.getInt("SAL");
System.out.println(empNo + " " + salary);
}
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}

When this program is running I have changes the value in SAL field but getting no effect in the ResultSet.

Please help me regarding this.
Regards,
Gourab
+Pie Number of slices to send: Send
Try to use DatabaseMetaData method
boolean othersUpdatesAreVisible(ResultSet.TYPE_SCROLL_SENSITIVE ) to find out whether your database and driver provide such a feature.
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 726 times.
Similar Threads
java.sql.SQLException: Before start of result set
Update statement not executing
Resultset processes 1 record
Scroll Sensitive ResultSet
JSP and ODBC
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:25:29.