[antlr-interest] Java Tree Parser Bug?
Todd Blanchard
todd.blanchard at cacheon.com
Fri Jan 18 13:26:32 PST 2002
For those working with the Java Tree Parser file, I made the following
modifications to it:
I added a java.util.ArrayList called stringLiterals to the class and
changed the constant rule to read:
constant
: NUM_INT
| CHAR_LITERAL
| s:STRING_LITERAL { stringLiterals.add(s.getText()); }
| NUM_FLOAT
| NUM_DOUBLE
| NUM_LONG
;
I then feed it this source but only the "somedatasource" literal makes
it into the list. Any insight into why that is would be great, thanks.
package com.cacheon.sample;
import javax.naming.*;
import java.sql.*;
import javax.sql.*;
import weblogic.jdbc.common.*;
import java.io.*;
/**
* Title: BlobWriter.java
* Description: BlobWriter that uses weblogic oci
* Copyright: Copyright (c) 2002
* Company: Abd Inc.
* @author Mr. PreviosCrappy Engineer
* @version 1.0
*/
public class BlobWriter {
public static void writeBlob(InputStream in, long someKey)
throws SQLException,IOException {
java.sql.Connection con = null;
java.sql.PreparedStatement pst = null;
java.sql.ResultSet rs = null;
java.io.OutputStream os = null;
try {
//get jdbc connection
con = getConnection();
//prepare the statement
pst = con.prepareStatement("SELECT SOME_BLOB FROM BLOB_TABLE WHERE
KEY = ?");
//set they key
pst.setLong(1, someKey);
//execute the query on the rdbs
rs = pst.executeQuery();
//if the empty blob column is found buffer out the data to the RDBMS
if (rs.next()) {
Blob myBlob = rs.getBlob(1);
os = ((weblogic.jdbc.common.OracleBlob)
myBlob).getBinaryOutputStream();
byte [] buf = new byte[4 * 1096];
int read = 0;
while((read = in.read(buf)) != -1) {
os.write(buf,0,read);
}
os.close();
in.close();
}
} finally {
//try and clean up
if (rs != null)
try {rs.close();} catch (SQLException sqle) {}
if (pst != null)
try {pst.close();} catch(SQLException sqle) {}
if (con != null)
try {con.close();} catch(SQLException sqle) {}
if (in != null)
try {in.close();} catch (IOException ioe) {}
if (os != null)
try {os.close();} catch (IOException ioe) {}
}
}
public static java.sql.Connection getConnection() throws SQLException
{
try {
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("somedatasource");
return ds.getConnection();
} catch (NamingException ne) {
throw new SQLException(ne.getMessage());
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20020118/acdaeced/attachment.html
More information about the antlr-interest
mailing list