Subject | Re: JDBC 1.5.0rc2 'invalid BLOB id' |
---|---|
Author | Roman Rokytskyy |
Post date | 2004-05-21T11:52:33Z |
Hi,
without any problems on my laptop (WinXP, FB 1.5.0, JayBird 1.5 RC3,
JDK 1.4)
import java.sql.*;
import org.firebirdsql.management.FBManager;
public class TestBlobWithView {
public static void main(String[] args) throws Exception {
FBManager manager = new FBManager();
manager.setForceCreate(true);
manager.start();
manager.createDatabase(
"c:/test_blob_view.fdb", "sysdba", "masterkey");
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection connection = DriverManager.getConnection(
"jdbc:firebirdsql:localhost/3050:c:/test_blob_view.fdb",
"sysdba",
"masterkey");
try {
Statement createStmt = connection.createStatement();
try {
createStmt.execute(
"UPDATE RDB$DATABASE " +
" SET RDB$CHARACTER_SET_NAME = 'WIN1251'");
createStmt.execute(
"CREATE TABLE SCREENSHOT_DATA (" +
" ENT_ID NUMERIC(18)," +
" DB_ID NUMERIC(18)," +
" DOC_ID NUMERIC(18)," +
" LINE_ORDER NUMERIC(18)," +
" SCREEN_PICTURE BLOB" +
")");
createStmt.execute(
"CREATE VIEW SCREENSHOT_V_DATA (" +
" ENT_ID," +
" DB_ID," +
" DOC_ID," +
" LINE_ORDER," +
" SCREEN_PICTURE" +
") AS" +
" SELECT ENT_ID, DB_ID, DOC_ID, " +
" LINE_ORDER, SCREEN_PICTURE FROM
SCREENSHOT_DATA;");
} finally {
createStmt.close();
}
PreparedStatement insertPs = connection.prepareStatement(
"INSERT INTO SCREENSHOT_V_DATA (" +
" ENT_ID, DB_ID, DOC_ID, LINE_ORDER,
SCREEN_PICTURE" +
") VALUES(?, ?, ?, ?, ?)");
try {
insertPs.setInt(1, 1);
insertPs.setInt(2, 1);
insertPs.setInt(3, 1);
insertPs.setInt(4, 1);
insertPs.setString(5, "Some test string");
insertPs.execute();
} finally {
insertPs.close();
}
Statement selectStmt = connection.createStatement();
try {
ResultSet rs = selectStmt.executeQuery(
"SELECT SCREEN_PICTURE FROM
SCREENSHOT_V_DATA");
if (!rs.next())
throw new Exception("Should find at least one
row");
if (!"Some test string".equals(rs.getString(1)))
throw new Exception("Incorrect BLOB value '" +
rs.getString(1) + "'");
if (rs.next())
throw new Exception("Should find only one row");
} finally {
selectStmt.close();
}
System.out.println("Test case works correctly.");
} finally {
connection.close();
}
} finally {
manager.dropDatabase("c:/test_blob_view.fdb", "sysdba",
"masterkey");
}
}
}
Please try it in your environment and modify it so the bug can be
reproduced.
was not able to reproduce it.
Thanks!
Roman
> This can be reproduced on any base.Here's test code that I created according to your comments. It works
without any problems on my laptop (WinXP, FB 1.5.0, JayBird 1.5 RC3,
JDK 1.4)
import java.sql.*;
import org.firebirdsql.management.FBManager;
public class TestBlobWithView {
public static void main(String[] args) throws Exception {
FBManager manager = new FBManager();
manager.setForceCreate(true);
manager.start();
manager.createDatabase(
"c:/test_blob_view.fdb", "sysdba", "masterkey");
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection connection = DriverManager.getConnection(
"jdbc:firebirdsql:localhost/3050:c:/test_blob_view.fdb",
"sysdba",
"masterkey");
try {
Statement createStmt = connection.createStatement();
try {
createStmt.execute(
"UPDATE RDB$DATABASE " +
" SET RDB$CHARACTER_SET_NAME = 'WIN1251'");
createStmt.execute(
"CREATE TABLE SCREENSHOT_DATA (" +
" ENT_ID NUMERIC(18)," +
" DB_ID NUMERIC(18)," +
" DOC_ID NUMERIC(18)," +
" LINE_ORDER NUMERIC(18)," +
" SCREEN_PICTURE BLOB" +
")");
createStmt.execute(
"CREATE VIEW SCREENSHOT_V_DATA (" +
" ENT_ID," +
" DB_ID," +
" DOC_ID," +
" LINE_ORDER," +
" SCREEN_PICTURE" +
") AS" +
" SELECT ENT_ID, DB_ID, DOC_ID, " +
" LINE_ORDER, SCREEN_PICTURE FROM
SCREENSHOT_DATA;");
} finally {
createStmt.close();
}
PreparedStatement insertPs = connection.prepareStatement(
"INSERT INTO SCREENSHOT_V_DATA (" +
" ENT_ID, DB_ID, DOC_ID, LINE_ORDER,
SCREEN_PICTURE" +
") VALUES(?, ?, ?, ?, ?)");
try {
insertPs.setInt(1, 1);
insertPs.setInt(2, 1);
insertPs.setInt(3, 1);
insertPs.setInt(4, 1);
insertPs.setString(5, "Some test string");
insertPs.execute();
} finally {
insertPs.close();
}
Statement selectStmt = connection.createStatement();
try {
ResultSet rs = selectStmt.executeQuery(
"SELECT SCREEN_PICTURE FROM
SCREENSHOT_V_DATA");
if (!rs.next())
throw new Exception("Should find at least one
row");
if (!"Some test string".equals(rs.getString(1)))
throw new Exception("Incorrect BLOB value '" +
rs.getString(1) + "'");
if (rs.next())
throw new Exception("Should find only one row");
} finally {
selectStmt.close();
}
System.out.println("Test case works correctly.");
} finally {
connection.close();
}
} finally {
manager.dropDatabase("c:/test_blob_view.fdb", "sysdba",
"masterkey");
}
}
}
Please try it in your environment and modify it so the bug can be
reproduced.
> I hope this bug will be fixed before final release.If it can be reproduced, it will be fixed before the release. So far I
was not able to reproduce it.
Thanks!
Roman