Hi Lance,
Thanks for your clarification. I created the test case you requested
and attached it in this email. Please review it. By the way, the new
Oracle bug (internal id 2376620) submitted by me several days ago seems
not having been reviewed. Could you also help me on this?
Best regards,
Frank
On 11/30/2012 8:40 PM, Lance Andersen - Oracle wrote:
Hi Frank,
Thank you for the email. No we do not want tests that require database access
in jtreg.
What I was trying to say, albeit not probably as clear as it could have been is
that it would be helpful to provide a complete example and to use Java DB as
the database if it is a generic data access issue as while it is not a required
part of the Java SE specification, we do provide it with the Oracle JDK so it
makes it easier to test against for developers vs finding an instance of DB2,
Sybase or even Oracle to test against.
Best
Lance
On Nov 30, 2012, at 12:26 AM, Frank Ding wrote:
Hi Lance,
Sorry for late response and thanks for your comment. You mean I can write a
jtreg test case that connects to Java DB? I can do that.
Best regards,
Frank
On 11/13/2012 10:13 PM, Lance Andersen - Oracle wrote:
Hi Frank,
Thank you for the note
If you could in the future, please provide a complete test program to repro
the issue as it would save time with the reviews. Ideally if the issue is not
database specific it would be good to leverage Java DB as it is included within
Oracle JDK
I will look at this sometime this week
Best
Lance
On Nov 12, 2012, at 9:25 PM, Frank Ding wrote:
Hi Lance
Thanks for your quick response. Please find the bug info below.
The problem:
When CachedRowSetImpl.acceptChanges() is called, incorrect number of
conflicts, if any, is reported. The number of conflicts is the actual number
of existing rows in database, which is the size of variable 'status' defined in
CachedRowSetWriter.writeData(). It's not the conflict number that is supposed
to be.
Test case:
The bug can be easily manifested in all SQL server environment. Here take
PostgreSQL for example.
1. The sql script to create a table
CREATE TABLE ressystem.roomdescription
(
roomdescription_id serial NOT NULL,
roomdescription character varying NOT NULL,
CONSTRAINT roomdescription_pkey PRIMARY KEY (roomdescription_id)
)
2. Manually insert 3 rows
(1, "Test 1")
(2, "Test 2")
(3, "Test 3")
3. Create a Java class that connects the established database and then
execute the following code snippet.
String query = "select roomdescription_id, roomdescription from
ressystem.roomdescription";
Object[] values = {2, "Test2"};
rs.setCommand(query);
rs.execute(conn);
rs.moveToInsertRow();
for(int i=0; i<values.length; i++) {
rs.updateObject(i+1,values[i]);
}
rs.insertRow();
rs.moveToCurrentRow();
rs.acceptChanges(conn);
4. An exception occurs with following output.
javax.sql.rowset.spi.SyncProviderException: 4conflicts while synchronizing
at
com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:412)
at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:880)
5. In fact, there is only one conflicting row but 4 were reported.
Best regards,
Frank
On 11/9/2012 7:41 PM, Lance Andersen - Oracle wrote:
Frank,
If you can please post the bug info here, I will take a look at your patch
Best
Lance
On Nov 8, 2012, at 10:01 PM, Frank Ding wrote:
Hi guys,
We discovered a bug in CachedRowSetWriter.writeData method where incorrect
number of conflicts is reported. I searched in Oracle bug database and no
similar record was found. So I submitted a new one whose internal review ID is
2376620. A test case with code is illustrated in the bug submission that
leverages PostgreSQL server but the issue is platform independent and easy to
reproduce.
I provided a patch review, available @
http://cr.openjdk.java.net/~dingxmin/2376620/webrev.01/
Is there anybody who is interested in patch and can also review bug 2376620?
Your reply is appreciated.
Best regards,
Frank
Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
lance.ander...@oracle.com
Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
lance.ander...@oracle.com
Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
lance.ander...@oracle.com
/*
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Portions Copyright (c) 2012 IBM Corporation
*/
import com.sun.rowset.CachedRowSetImpl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import javax.sql.rowset.CachedRowSet;
public class DerbyTest {
private static String DERBY_DB_FILE = "derbydb";
private static Connection getConnection() throws Exception {
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String url = "jdbc:derby:" + DERBY_DB_FILE + ";create=true";
Connection conn;
try {
Class.forName(driver);
conn = DriverManager.getConnection(url);
} catch (Exception e) {
throw e;
}
return conn;
}
private static void createTable(Connection conn) throws SQLException {
Statement statement = conn.createStatement();
try {
statement.execute("DROP TABLE mytable");
} catch (SQLException ex) {
// ignore exception when mytable doesn't exist
}
String createTableSQL = "CREATE TABLE mytable"
+ "(id INT NOT NULL PRIMARY KEY,"
+ "description VARCHAR(30) NOT NULL)";
statement.executeUpdate(createTableSQL);
statement.close();
}
private static void prepareData(Connection conn) throws SQLException {
Statement statement = conn.createStatement();
String insertTableData = "INSERT INTO mytable(id,description)"
+ "VALUES(1, 'r1')";
statement.executeUpdate(insertTableData);
insertTableData = "INSERT INTO mytable(id,description)"
+ "VALUES(2, 'r2')";
statement.executeUpdate(insertTableData);
statement.close();
}
private static void createConflict(Connection conn) throws SQLException {
CachedRowSet rs = new CachedRowSetImpl();
rs.setReadOnly(false);
String querySql = "SELECT id, description FROM mytable";
rs.setCommand(querySql);
rs.execute(conn);
rs.moveToInsertRow();
rs.updateObject(1, 2);
rs.updateObject(2, "new str");
rs.insertRow();
rs.moveToCurrentRow();
rs.acceptChanges(conn);
}
public static void main(String[] args) throws Exception {
Connection conn = getConnection();
createTable(conn);
prepareData(conn);
try {
createConflict(conn);
} catch (SQLException ex) {
String errMsg = ex.getMessage();
if (!errMsg.startsWith("1")) {
System.out.println("The conflict number should be 1 but now " +
"it is " + errMsg);
throw ex;
}
}
conn.close();
}
}