[antlr-interest] Java Tree Parser Bug?
mzukowski at bco.com
mzukowski at bco.com
Fri Jan 18 13:58:36 PST 2002
Try the -traceParser option to antlr.Tool to see what rules are called. Is
STRING_LITERAL anywhere else in the grammar?
Monty
-----Original Message-----
From: Todd Blanchard [mailto:todd.blanchard at cacheon.com]
Sent: Friday, January 18, 2002 1:27 PM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Java Tree Parser Bug?
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());
}
}
}
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list