1. Without Weblogic pool:
1.1. Java logic
public void insert(StoredFilesPK _sfpk, String _name, String _email, String
_pdfFilename)
throws SQLException
{
log.debug("insert");
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the database
Connection conn =
DriverManager.getConnection ("jdbc:oracle:thin:@10.10.10.10:1521:xxx",
"xxx", "12345");
System.out.println("Connected");
// This is absolutely necessary in this case and any case where
you are doing
// a select for update. Not doing this will result in a ORA-1002
conn.setAutoCommit (false);
BLOB blob = null;
// Create a Statement
Statement stmt = conn.createStatement ();
// Drop the table if it exists
try {
stmt.execute ("drop table ImageTable4");
System.out.println("Table droped ...");
}
catch (SQLException e) {
System.out.println("Table does not exist");
}
// Create the table
stmt.execute ("create table ImageTable4 (count varchar2(20),
image BLOB)");
System.out.println("Table created ...");
// create a blob entry in the table
stmt.execute("insert into ImageTable4 values ('one', empty_blob())");
stmt.execute("commit");
System.out.println("inserted empty blob");
String cmd = "select * from ImageTable4 for update";
ResultSet rset = stmt.executeQuery(cmd);
if (rset.next()) {
blob = ((OracleResultSet)rset).getBLOB(2);
System.out.println("got blob reference");
}
else System.out.println("no row to get!!!!");
rset.close();
readFromFile(blob);
cmd = "update ImageTable4 set image = ? where count = 'one'";
PreparedStatement pstmt = conn.prepareStatement(cmd);
pstmt.setBlob(1, blob);
pstmt.execute();
stmt.execute("commit");
System.out.println("blob updated");
blob = null;
cmd = "select * from ImageTable4 for update";
rset = stmt.executeQuery(cmd);
if (rset.next()) {
System.out.println("get blob");
blob = ((OracleResultSet)rset).getBLOB(2);
System.out.println("got blob, writing to file");
writeToFile(blob);
}
else System.out.println("no row to get (2)!!!!");
}
catch (SQLException sqle) {
System.out.println("SQL Exception occured: " + sqle.getMessage());
sqle.printStackTrace();
}
catch(FileNotFoundException e) {
System.out.println("File Not Found");
}
catch (IOException ioe) {
System.out.println("IO Exception" + ioe.getMessage());
}
catch (Exception ioe) {
System.out.println("Exception" + ioe.getMessage());
}
}
2. Using Weblogic Pool
2.1. Java logic
Pretty much the same before, just the way to get the connection:
public void insert(StoredFilesPK _sfpk, String _name, String _email, String
_pdfFilename)
throws SQLException
{
log.debug("insert");
try {
// Connect to the database
InitialContext ctx = new InitialContext();
DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/eDeliveryDSRef");
Connection conn = ds.getConnection();
System.out.println("Connected");
(and so on, like 1.1)
2.2 Weblogic errors
<19/07/2002 13h50min57s BRT> <Debug> <eDelivery> <insert>
Connected
Table droped ...
Table created ...
inserted empty blob
Exceptionweblogic.jdbc.rmi.SerialResultSet
<19/07/2002 13h50min57s BRT> <Debug> <eDelivery> <paramId=PRCWebDirTemp; paramCo
untryId=0>
<19/07/2002 13h50min58s BRT> <Info> <JDBC> <Connection for pool "eDeliveryBEA"
c
reated.>
<19/07/2002 13h50min58s BRT> <Debug> <eDelivery> <ReadConfig value: K:>
<19/07/2002 13h50min58s BRT> <Info> <EJB> <EJB Exception during invocation from
home: eDelivery.StoredFilesBean_62xt1l_HomeImpl@1665b6 threw exception: javax.ej
b.EJBException: ERROR in getPDFFile: weblogic.jdbc.rmi.SerialOracleBlob
javax.ejb.EJBException: ERROR in getPDFFile: weblogic.jdbc.rmi.SerialOracleBlob
at eDelivery.StoredFilesBean.getPDFFile(StoredFilesBean.java:127)
at eDelivery.StoredFilesBean_62xt1l_EOImpl.getPDFFile(StoredFilesBean_62
xt1l_EOImpl.java:125)
at jsp_servlet._public_45_root.__testenewstoredfiles._jspService(__teste
newstoredfiles.java:123)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:304)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2456)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2039)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
<19/07/2002 13h50min58s BRT> <Error> <HTTP> <[WebAppServletContext(4815271,eDeli
very,/eDelivery)] Servlet failed with IOException
java.rmi.RemoteException: EJB Exception: ; nested exception is:
javax.ejb.EJBException: ERROR in getPDFFile: weblogic.jdbc.rmi.SerialOra
cleBlob
javax.ejb.EJBException: ERROR in getPDFFile: weblogic.jdbc.rmi.SerialOracleBlob
at eDelivery.StoredFilesBean.getPDFFile(StoredFilesBean.java:127)
at eDelivery.StoredFilesBean_62xt1l_EOImpl.getPDFFile(StoredFilesBean_62
xt1l_EOImpl.java:125)
at jsp_servlet._public_45_root.__testenewstoredfiles._jspService(__teste
newstoredfiles.java:123)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:304)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2456)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2039)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
2.3 Pool and Datasource Definition at config.xml
<JDBCDataSource JNDIName="jdbc.eDeliveryDS"
Name="eDeliveryDataSource" PoolName="BEA" Targets="SERVER"/>
<JDBCConnectionPool DriverName="oracle.jdbc.driver.OracleDriver"
MaxCapacity="10" Name="BEA"
Password="{3DES}Zvp/p1JWojE="
Properties="user=xxx;weblogic.t3.waitForConnection=true;weblogic.t3.waitSecondsForConnection=999999999999,weblogic.jts.waitSecondsForConnectionSecs=999999999999,verbose=false"
Targets="SERVER" URL="jdbc:oracle:thin:@10.10.10.10:1521:xxx"/>
Can anybody have any clues?
Thanks in advance!!
5.1:
myBlob = (oracle.sql.BLOB)result.getBlob(1); // Get BLOB handle
6.1:
weblogic.jdbc.rmi.SerialOracleBlob cast1 =
(weblogic.jdbc.rmi.SerialOracleBlob)result.getBlob(1);
weblogic.jdbc.rmi.internal.OracleTBlobImpl cast2 =
(weblogic.jdbc.rmi.internal.OracleTBlobImpl)cast1.getTheRealBlob();
myBlob = (oracle.sql.BLOB)cast2.getTheRealBlob(); // Get BLOB handle
I'm not sure that this is the best solution (It breaks sourcecode
compatibility between 5.1 and 6.1), but
it works.
Gordon
"Claudio Cabaleiro" <claudio....@br.unisys.com> wrote in message
news:3d404ce2$1...@newsgroups.bea.com...