When DataSetResolver.syncRow() is used, it is given the following message.
Exception in thread "main" java.lang.UnsupportedOperationException: Operation not yet supported
at com.sun.sql.DataSetResolverImpl.syncRow(DataSetResolverImpl.java:40)
at QueryTest.doTest(QueryTest.java:88)
at QueryTest.main(QueryTest.java:117)
change the IP, username and user passwd.
javac QueryTest.java
java QueryTest
Sample program
===============
PersonDO.java
--------
import java.sql.ResultColumn;
public class PersonDO {
@ResultColumn(uniqueIdentifier=true)public long id ;
public String firstName ;
public String lastName ;
}
QueryTest.java
----------------
import java.sql.*;
public class QueryTest {
Connection conn = null;
Connection conn1 = null;
Statement stmt = null;
private void doSetup() {
try {
Class.forName("com.inet.ora.OraDriver");
}catch (ClassNotFoundException ex) {
System.err.println("Exception when loading JDBC driver : "+ex);
}
try {
conn = DriverManager.getConnection("jdbc:inetora:IP:1521:ORCL", "user", "passwd");
conn1 = DriverManager.getConnection("jdbc:inetora:IP:1521:ORCL", "user", "passwd");
stmt = conn.createStatement();
stmt.executeUpdate("drop table query001");
}catch (SQLException ex) {
System.err.println("Exception : "+ex);
}
try {
stmt.addBatch("create table query001 ( id number, firstName varchar2(32), lastName varchar2(32), primary key (id))");
stmt.addBatch("insert into query001 values ( 1, 'fname1', 'last_name1')");
stmt.addBatch("insert into query001 values ( 2, 'fname2', 'last_name2')");
stmt.executeBatch();
}catch (SQLException ex) {
System.err.println("Exception when executing SQL :"+ex);
}
}
private void doTest() {
DataSet<PersonDO> rows = null;
I_Query001 query = null;
try {
query = QueryObjectFactory.createQueryObject(I_Query001.class, conn);
} catch (SQLException sqlEx) {
System.err.println("SQLException caught "+sqlEx.getMessage());
}
System.out.println("Calling query.getAllPersons() ...");
rows = query.getAllPersons();
System.out.println("DataSet.size="+rows.size());
for(PersonDO p : rows) {
if( p.id == 1)
p.firstName = "syncproblemFirst";
rows.modify();
System.out.println("Id: "+p.id+" First Name: "+p.firstName+" Last Name: "+p.lastName);
}
// Here change the value in the DB. This should cause a sync problem.
try {
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from query001");
while(rs.next()) {
if(rs.getInt(1) == 1) {
rs.updateString(2,"thiiswrong");
rs.updateRow();
System.out.println("Updated the result set row");
}
}
} catch(Exception e) {
System.out.println("Unexpected Exception: "+e.getMessage());
}
try
{
rows.sync();
} catch(SQLDataSetSyncException spe) {
System.out.println("Caught : "+spe.getMessage());
DataSetResolver<ConflictingRow> ds = spe.getDataSetResolver();
for(ConflictingRow cr : ds) {
PersonDO pd = (PersonDO)cr.getRow();
System.out.println("pd id: "+pd.id);
System.out.println("pd firstName: "+pd.firstName);
System.out.println("pd lastName: "+pd.lastName);
//pd.firstName = "thiiswrong";
pd.firstName = "syncproblemFirst";
ds.syncRow();
}
}
rows = query.getAllPersons();
System.out.println("After syncing....");
for(PersonDO p : rows) {
System.out.println("Id: "+p.id+" First Name: "+p.firstName+" Last Name: "+p.lastName);
}
/*
System.out.println("Modify again ....");
for(PersonDO p : rows) {
if( p.id == 1)
p.firstName = "ModifyAgainFirst";
rows.modify();
System.out.println("Id: "+p.id+" First Name: "+p.firstName+" Last Name: "+p.lastName);
}
try
{
rows.sync();
} catch(SQLDataSetSyncException spe) {
System.out.println ("SQLDataSetSyncExc again");
}*/
}
public static void main(String[] args) {
QueryTest qtest = new QueryTest();
qtest.doSetup();
qtest.doTest();
}
}
interface I_Query001 extends BaseQuery {
@Select(sql="SELECT id , firstName, lastName from query001",connected=false,tableName="query001",readOnly=false)
DataSet<PersonDO> getAllPersons() ;
}
This test also fails because of this bug:
java_sql_eod/dataset/DataSet008_005 compile_and_execute
Closing this bug, since the method cannot be implemented without a change to the RowSet spec. Method will be removed.
Sorry, I closed the bug prematurely. Reopening as "Cause Known" so SQE can keep track of this. Will close after CCC.
Exception in thread "main" java.lang.UnsupportedOperationException: Operation not yet supported
at com.sun.sql.DataSetResolverImpl.syncRow(DataSetResolverImpl.java:40)
at QueryTest.doTest(QueryTest.java:88)
at QueryTest.main(QueryTest.java:117)
change the IP, username and user passwd.
javac QueryTest.java
java QueryTest
Sample program
===============
PersonDO.java
--------
import java.sql.ResultColumn;
public class PersonDO {
@ResultColumn(uniqueIdentifier=true)public long id ;
public String firstName ;
public String lastName ;
}
QueryTest.java
----------------
import java.sql.*;
public class QueryTest {
Connection conn = null;
Connection conn1 = null;
Statement stmt = null;
private void doSetup() {
try {
Class.forName("com.inet.ora.OraDriver");
}catch (ClassNotFoundException ex) {
System.err.println("Exception when loading JDBC driver : "+ex);
}
try {
conn = DriverManager.getConnection("jdbc:inetora:IP:1521:ORCL", "user", "passwd");
conn1 = DriverManager.getConnection("jdbc:inetora:IP:1521:ORCL", "user", "passwd");
stmt = conn.createStatement();
stmt.executeUpdate("drop table query001");
}catch (SQLException ex) {
System.err.println("Exception : "+ex);
}
try {
stmt.addBatch("create table query001 ( id number, firstName varchar2(32), lastName varchar2(32), primary key (id))");
stmt.addBatch("insert into query001 values ( 1, 'fname1', 'last_name1')");
stmt.addBatch("insert into query001 values ( 2, 'fname2', 'last_name2')");
stmt.executeBatch();
}catch (SQLException ex) {
System.err.println("Exception when executing SQL :"+ex);
}
}
private void doTest() {
DataSet<PersonDO> rows = null;
I_Query001 query = null;
try {
query = QueryObjectFactory.createQueryObject(I_Query001.class, conn);
} catch (SQLException sqlEx) {
System.err.println("SQLException caught "+sqlEx.getMessage());
}
System.out.println("Calling query.getAllPersons() ...");
rows = query.getAllPersons();
System.out.println("DataSet.size="+rows.size());
for(PersonDO p : rows) {
if( p.id == 1)
p.firstName = "syncproblemFirst";
rows.modify();
System.out.println("Id: "+p.id+" First Name: "+p.firstName+" Last Name: "+p.lastName);
}
// Here change the value in the DB. This should cause a sync problem.
try {
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from query001");
while(rs.next()) {
if(rs.getInt(1) == 1) {
rs.updateString(2,"thiiswrong");
rs.updateRow();
System.out.println("Updated the result set row");
}
}
} catch(Exception e) {
System.out.println("Unexpected Exception: "+e.getMessage());
}
try
{
rows.sync();
} catch(SQLDataSetSyncException spe) {
System.out.println("Caught : "+spe.getMessage());
DataSetResolver<ConflictingRow> ds = spe.getDataSetResolver();
for(ConflictingRow cr : ds) {
PersonDO pd = (PersonDO)cr.getRow();
System.out.println("pd id: "+pd.id);
System.out.println("pd firstName: "+pd.firstName);
System.out.println("pd lastName: "+pd.lastName);
//pd.firstName = "thiiswrong";
pd.firstName = "syncproblemFirst";
ds.syncRow();
}
}
rows = query.getAllPersons();
System.out.println("After syncing....");
for(PersonDO p : rows) {
System.out.println("Id: "+p.id+" First Name: "+p.firstName+" Last Name: "+p.lastName);
}
/*
System.out.println("Modify again ....");
for(PersonDO p : rows) {
if( p.id == 1)
p.firstName = "ModifyAgainFirst";
rows.modify();
System.out.println("Id: "+p.id+" First Name: "+p.firstName+" Last Name: "+p.lastName);
}
try
{
rows.sync();
} catch(SQLDataSetSyncException spe) {
System.out.println ("SQLDataSetSyncExc again");
}*/
}
public static void main(String[] args) {
QueryTest qtest = new QueryTest();
qtest.doSetup();
qtest.doTest();
}
}
interface I_Query001 extends BaseQuery {
@Select(sql="SELECT id , firstName, lastName from query001",connected=false,tableName="query001",readOnly=false)
DataSet<PersonDO> getAllPersons() ;
}
This test also fails because of this bug:
java_sql_eod/dataset/DataSet008_005 compile_and_execute
Closing this bug, since the method cannot be implemented without a change to the RowSet spec. Method will be removed.
Sorry, I closed the bug prematurely. Reopening as "Cause Known" so SQE can keep track of this. Will close after CCC.