Subject | Re: [firebird-support] BLOB not found |
---|---|
Author | Santini |
Post date | 2004-02-18T01:36:07Z |
Helen,
The database that I'm developing is in inital phase (database model). So,
I'm working with only one table and migrating data from a ISIS database
(www.unesco.org/isis) to this table and performing same tests.
I will try not specify the segment size.
The database was created many times from the script.
I belive that the application (client) can't corrupt a database, but...
engine.
My Java application is the following:
public class Importa {
private static final int MAXAREA = 8192;
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws ClassNotFoundException,
SQLException {
/* Determina as propriedades de conexão do banco. */
java.util.Properties propsConexao = new java.util.Properties();
propsConexao.put("user", "SYSDBA");
propsConexao.put("password", "masterkey");
propsConexao.put("lc_ctype", "ISO8859_1");
/* Carrega o driver JayBird. */
Class.forName("org.firebirdsql.jdbc.FBDriver");
/* Monta a string de conexão e conecta-se ao banco. */
String dbURL =
"jdbc:firebirdsql:localhost:c:\\software\\webmarc\\db\\webmarc.fdb";
Connection conn = DriverManager.getConnection(dbURL, propsConexao);
/* Carrega a ISIS_DLL. */
int appHandle = ISISAPI.IsisAppNew();
/* Cria um ISIS space. */
int spaHandle = ISISAPI.IsisSpaNew(appHandle);
/* Abre a base de dados ISIS. */
ISISAPI.IsisSpaMf(spaHandle, args[0]);
/* Determina a quantidade de MFNs existentes na base ISIS. */
ISISJAVA.IsisRecControl control = new ISISJAVA.IsisRecControl();
ISISAPI.IsisRecControlMap(spaHandle, control);
int maxMfn = control.nxtmfn - 1;
/* Importa os dados da base ISIS para o banco Firebird. */
String sql = "INSERT INTO BSMST (MFN, OCC, SUB, TAG, VAL) " +
"VALUES (?, ?, ?, ?, ?)";
PreparedStatement pstmt = conn.prepareStatement(sql);
String area[] = new String[MAXAREA];
for (int mfn = 1; mfn <= maxMfn; mfn++) {
System.out.println(mfn);
ISISAPI.IsisRecRead(spaHandle, 0, mfn);
for (int tag = 1; tag <= 999; tag++) {
int totalOcc = ISISAPI.IsisRecFieldOcc(spaHandle, 0, tag);
for (int occ = 1; occ <= totalOcc; occ++) {
ISISAPI.IsisRecField(spaHandle, 0, tag, occ, area,
MAXAREA);
pstmt.setInt(1, mfn);
pstmt.setInt(2, occ);
pstmt.setInt(4, tag);
if (area[0].indexOf("^") == -1) {
pstmt.setString(3, "*");
ByteArrayInputStream bais = new
ByteArrayInputStream(area[0].getBytes());
pstmt.setBinaryStream(5, bais,
area[0].getBytes().length);
pstmt.executeUpdate();
} else {
if (! area[0].substring(0, 1).equals("^"))
area[0] = "^*" + area[0];
StringTokenizer subs = new StringTokenizer(area[0],
"^");
while (subs.hasMoreTokens()) {
String s = subs.nextToken();
pstmt.setString(3, s.substring(0, 1));
ByteArrayInputStream bais = new
ByteArrayInputStream(s.substring(1).getBytes());
pstmt.setBinaryStream(5, bais,
s.substring(1).getBytes().length);
pstmt.executeUpdate();
}
}
}
}
}
}
}
Thanks,
Rafael Santini
> You mention in another message that you are using Java as yourexplicitly.
> interface. This means you are using the API (not embedded SQL) so I
> recommend that you rebuild that table (using a gbak copy of the database)
> and omit the SEGMENT SIZE parameter. I don't *know* that specifying a
> segment size would cause a problem...but my understanding is that the API
> does its own thing with blob segments and the error you reported involved
> segment lengths, as I recall. Maybe your driver is doing something
> unpredictable on the basis of your having defined a segment size
The database that I'm developing is in inital phase (database model). So,
I'm working with only one table and migrating data from a ISIS database
(www.unesco.org/isis) to this table and performing same tests.
I will try not specify the segment size.
The database was created many times from the script.
I belive that the application (client) can't corrupt a database, but...
> Another thing I do know about WRT blobs is that their database page-linksThe database isn't copied, it is created before my tests.
> can get broken if you work on file-copy copies of your database. The
> problems can show up long after you actually make the copy, if the blobs
> are not accessed for some time.
> Large blobs are also prone to errors during operations if you are using aThe tests are performed in my workstation.
> system with faulty RAM or a bad network connection.
> Also, if you're not using the Firebird JDBC driver, then you should.I'm using Jaybird.
> It would make sense for you to post your problem in the Firebird-Javaforum
> if you find it persists.This not make sense for me. I belive that the problem is with database
engine.
My Java application is the following:
public class Importa {
private static final int MAXAREA = 8192;
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws ClassNotFoundException,
SQLException {
/* Determina as propriedades de conexão do banco. */
java.util.Properties propsConexao = new java.util.Properties();
propsConexao.put("user", "SYSDBA");
propsConexao.put("password", "masterkey");
propsConexao.put("lc_ctype", "ISO8859_1");
/* Carrega o driver JayBird. */
Class.forName("org.firebirdsql.jdbc.FBDriver");
/* Monta a string de conexão e conecta-se ao banco. */
String dbURL =
"jdbc:firebirdsql:localhost:c:\\software\\webmarc\\db\\webmarc.fdb";
Connection conn = DriverManager.getConnection(dbURL, propsConexao);
/* Carrega a ISIS_DLL. */
int appHandle = ISISAPI.IsisAppNew();
/* Cria um ISIS space. */
int spaHandle = ISISAPI.IsisSpaNew(appHandle);
/* Abre a base de dados ISIS. */
ISISAPI.IsisSpaMf(spaHandle, args[0]);
/* Determina a quantidade de MFNs existentes na base ISIS. */
ISISJAVA.IsisRecControl control = new ISISJAVA.IsisRecControl();
ISISAPI.IsisRecControlMap(spaHandle, control);
int maxMfn = control.nxtmfn - 1;
/* Importa os dados da base ISIS para o banco Firebird. */
String sql = "INSERT INTO BSMST (MFN, OCC, SUB, TAG, VAL) " +
"VALUES (?, ?, ?, ?, ?)";
PreparedStatement pstmt = conn.prepareStatement(sql);
String area[] = new String[MAXAREA];
for (int mfn = 1; mfn <= maxMfn; mfn++) {
System.out.println(mfn);
ISISAPI.IsisRecRead(spaHandle, 0, mfn);
for (int tag = 1; tag <= 999; tag++) {
int totalOcc = ISISAPI.IsisRecFieldOcc(spaHandle, 0, tag);
for (int occ = 1; occ <= totalOcc; occ++) {
ISISAPI.IsisRecField(spaHandle, 0, tag, occ, area,
MAXAREA);
pstmt.setInt(1, mfn);
pstmt.setInt(2, occ);
pstmt.setInt(4, tag);
if (area[0].indexOf("^") == -1) {
pstmt.setString(3, "*");
ByteArrayInputStream bais = new
ByteArrayInputStream(area[0].getBytes());
pstmt.setBinaryStream(5, bais,
area[0].getBytes().length);
pstmt.executeUpdate();
} else {
if (! area[0].substring(0, 1).equals("^"))
area[0] = "^*" + area[0];
StringTokenizer subs = new StringTokenizer(area[0],
"^");
while (subs.hasMoreTokens()) {
String s = subs.nextToken();
pstmt.setString(3, s.substring(0, 1));
ByteArrayInputStream bais = new
ByteArrayInputStream(s.substring(1).getBytes());
pstmt.setBinaryStream(5, bais,
s.substring(1).getBytes().length);
pstmt.executeUpdate();
}
}
}
}
}
}
}
Thanks,
Rafael Santini