JDK : 1.6.0-b40 with latest CVS checkout of JDBC4.0 workspace
DB : ORCL.
Execute a @Query with allColumnsMapped=false. Ensure that the UDT class has more fields than columns returned by SELECT query. Upon executing the @Query, the DataSet does not have values as expected.
Not sure if this is covered as part of fix for 6281207.
Here is a simple test to reproduce this problem.
--- QueryTest.java ----------------------------------------------------
import java.sql.*;
public class QueryTest {
Connection conn = 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:10.5.21.11:1521:ORCL", "ashwin", "ashwin");
stmt = conn.createStatement();
}catch (SQLException ex) {
System.err.println("Exception : "+ex);
}
try {
stmt.executeUpdate("delete from query001");
stmt.executeUpdate("drop table query001");
}catch (SQLException sqlEx) {}
try {
stmt.addBatch("create table query001 ( id number, firstName varchar2(32), lastName varchar2(32), age int, primary key (id))");
stmt.addBatch("insert into query001 values ( 1, 'Moises', 'Alou', 39 )");
stmt.addBatch("insert into query001 values ( 2, 'Mike', 'Matheney', 35 )");
stmt.addBatch("insert into query001 values ( 3, 'Omar', 'Visquel', 38 )");
stmt.executeBatch();
}catch (SQLException ex) {
System.err.println("Exception when executing SQL :"+ex);
}
}
private void doTest() {
I_QueryTest query = null;
DataSet<PersonDO> rows = null;
try {
query = QueryObjectFactory.createDefaultQueryObject(I_QueryTest.class, conn);
} catch (SQLException sqlEx) {
System.err.println("SQLException caught "+sqlEx.getMessage());
}
try {
rows = query.getAllPersons();
}catch (Exception ex) {
System.err.println("doTest() : Exception caught when executing @Query : "+ex.getMessage());
ex.printStackTrace();
return;
}
System.out.println("****** Printing contents of DataSet ******** ");
for (PersonDO person : rows) {
System.out.println("id="+person.id);
System.out.println("lastName="+person.lastName);
}
System.out.println("\n****** Printing contents of ResultSet ******** ");
ResultSet rs = null;
try {
rs = stmt.executeQuery("SELECT id, lastName from query001");
while (rs.next()) {
System.out.println(" id ="+rs.getLong("id"));
System.out.println(" lastName ="+rs.getString("lastName"));
}
}catch (SQLException ex) {
System.out.println("SQLException :"+ex.getMessage());
}
finally {
//close resources
}
}
public static void main(String[] args) {
QueryTest qtest = new QueryTest();
qtest.doSetup();
qtest.doTest();
}
}
interface I_QueryTest extends BaseQuery {
@Query(sql="SELECT id, lastName from query001", allColumnsMapped=false)
DataSet<PersonDO> getAllPersons();
}
--- PersonDO.java ----------------------------------------------------
public class PersonDO {
public long id ;
public String firstName ;
public String lastName ;
public boolean elite_status ;
public int age ;
}
----------------------------------------------------------------------
ar138791@wunderland % /local/jdk/jdk1.6.0-b40/bin/javac -J-Xbootclasspath/p:/home/ar138791/ws/other_ws/jdbc4.0/build/jdbc4.jar QueryTest.java
ar138791@wunderland % /local/jdk/jdk1.6.0-b40/bin/java -cp ~/ws/dev_ws/jdbc/jdbc4.0_mustang_ws/6.0/jdbc/share/drivers/inet/Oranxo.jar:. -Xbootclasspath/p:/home/ar138791/ws/other_ws/jdbc4.0/build/jdbc4.jar QueryTest
****** Printing contents of DataSet ********
id=1
lastName=null
id=2
lastName=null
id=3
lastName=null
****** Printing contents of ResultSet ********
id =1
lastName =Alou
id =2
lastName =Matheney
id =3
lastName =Visquel
ar138791@wunderland %
---------------------------------------------------------------------------
###@###.### 2005-06-14 00:01:34 GMT
DB : ORCL.
Execute a @Query with allColumnsMapped=false. Ensure that the UDT class has more fields than columns returned by SELECT query. Upon executing the @Query, the DataSet does not have values as expected.
Not sure if this is covered as part of fix for 6281207.
Here is a simple test to reproduce this problem.
--- QueryTest.java ----------------------------------------------------
import java.sql.*;
public class QueryTest {
Connection conn = 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:10.5.21.11:1521:ORCL", "ashwin", "ashwin");
stmt = conn.createStatement();
}catch (SQLException ex) {
System.err.println("Exception : "+ex);
}
try {
stmt.executeUpdate("delete from query001");
stmt.executeUpdate("drop table query001");
}catch (SQLException sqlEx) {}
try {
stmt.addBatch("create table query001 ( id number, firstName varchar2(32), lastName varchar2(32), age int, primary key (id))");
stmt.addBatch("insert into query001 values ( 1, 'Moises', 'Alou', 39 )");
stmt.addBatch("insert into query001 values ( 2, 'Mike', 'Matheney', 35 )");
stmt.addBatch("insert into query001 values ( 3, 'Omar', 'Visquel', 38 )");
stmt.executeBatch();
}catch (SQLException ex) {
System.err.println("Exception when executing SQL :"+ex);
}
}
private void doTest() {
I_QueryTest query = null;
DataSet<PersonDO> rows = null;
try {
query = QueryObjectFactory.createDefaultQueryObject(I_QueryTest.class, conn);
} catch (SQLException sqlEx) {
System.err.println("SQLException caught "+sqlEx.getMessage());
}
try {
rows = query.getAllPersons();
}catch (Exception ex) {
System.err.println("doTest() : Exception caught when executing @Query : "+ex.getMessage());
ex.printStackTrace();
return;
}
System.out.println("****** Printing contents of DataSet ******** ");
for (PersonDO person : rows) {
System.out.println("id="+person.id);
System.out.println("lastName="+person.lastName);
}
System.out.println("\n****** Printing contents of ResultSet ******** ");
ResultSet rs = null;
try {
rs = stmt.executeQuery("SELECT id, lastName from query001");
while (rs.next()) {
System.out.println(" id ="+rs.getLong("id"));
System.out.println(" lastName ="+rs.getString("lastName"));
}
}catch (SQLException ex) {
System.out.println("SQLException :"+ex.getMessage());
}
finally {
//close resources
}
}
public static void main(String[] args) {
QueryTest qtest = new QueryTest();
qtest.doSetup();
qtest.doTest();
}
}
interface I_QueryTest extends BaseQuery {
@Query(sql="SELECT id, lastName from query001", allColumnsMapped=false)
DataSet<PersonDO> getAllPersons();
}
--- PersonDO.java ----------------------------------------------------
public class PersonDO {
public long id ;
public String firstName ;
public String lastName ;
public boolean elite_status ;
public int age ;
}
----------------------------------------------------------------------
ar138791@wunderland % /local/jdk/jdk1.6.0-b40/bin/javac -J-Xbootclasspath/p:/home/ar138791/ws/other_ws/jdbc4.0/build/jdbc4.jar QueryTest.java
ar138791@wunderland % /local/jdk/jdk1.6.0-b40/bin/java -cp ~/ws/dev_ws/jdbc/jdbc4.0_mustang_ws/6.0/jdbc/share/drivers/inet/Oranxo.jar:. -Xbootclasspath/p:/home/ar138791/ws/other_ws/jdbc4.0/build/jdbc4.jar QueryTest
****** Printing contents of DataSet ********
id=1
lastName=null
id=2
lastName=null
id=3
lastName=null
****** Printing contents of ResultSet ********
id =1
lastName =Alou
id =2
lastName =Matheney
id =3
lastName =Visquel
ar138791@wunderland %
---------------------------------------------------------------------------
###@###.### 2005-06-14 00:01:34 GMT