[jboss-user] [EJB/JBoss] - we're going to insert CLOB data in oracle db, using jboss4.0
ljg76
do-not-reply at jboss.com
Thu Jun 21 04:50:45 EDT 2007
hi?
Nice meet you
when we insert CLOB data in oracle db, using jboss4.0.4,
we have a problem.
if you want to disclose a error cause, you must compare two source.
first java source has a matter, second jsp source hasn't any error.
i want to known a case of first source error.
The following first source has a NoClassDefFoundError of jboss/resource/adapter/jdbc/WrappedConnection
--------------------------------------------------------------------------------------
/*
* Classname : DataChange.java
* Version information : v 1.0
*/
import java.sql.Clob;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.io.StringWriter;
import java.io.StringReader;
import oracle.sql.CLOB;
import org.jboss.resource.adapter.jdbc.WrappedConnection;
public class EpiaClobUtil
{
public static Clob createClob(Connection con, String string) throws SQLException
{
CLOB clob = null;
boolean bOk = false;
WrappedConnection wc = null;
System.out.println("wc : " + wc);
try
{
wc= (WrappedConnection) con;
Connection oracleConnection=wc.getUnderlyingConnection();
clob = CLOB.createTemporary(oracleConnection, true, CLOB.DURATION_SESSION);
clob.open(CLOB.MODE_READWRITE);
BufferedWriter bw = new BufferedWriter(clob.getCharacterOutputStream());
try
{
bw.write(string, 0, string.length());
bw.close();
}
catch (IOException e)
{
System.out.println("createClob5" + e);
System.out.println("createClob51" + e.getMessage() );
}
bOk = true;
}catch(Exception e1){
e1.printStackTrace();
System.out.println("createClob11" + e1);
}
finally
{
if (!bOk && clob != null)
{
try
{
CLOB.freeTemporary(clob);
}
catch (SQLException e)
{
e.printStackTrace();
System.out.println("createClob8" + e);
}
clob = null;
}
}
return clob;
}
}
------------------------------------------------------------------------------------
The Following Second Source has not any problem
------------------------------------------------------------------------------------
<%@ page contentType="text/html; charset=euc-kr" session="true"%>
<%@ page import = " java.util.*,
java.text.*,
java.io.*,
java.sql.*,
javax.sql.*,
com.ehigh.univdbfwl.*,
javax.naming.*,
org.jboss.resource.adapter.jdbc.WrappedConnection"
%>
<%
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
Connection con = ds.getConnection();
System.out.println("First Connection --> "+con.toString()+"");
out.println("First Connection --> "+con.toString()+"");
if(con instanceof WrappedConnection){
System.out.println("Yes instanceof");
out.println("Yes instanceof");
WrappedConnection wc=(WrappedConnection)con;
Connection oracleConnection=wc.getUnderlyingConnection();
}else{
System.out.println("No instanceof");
out.println("No instanceof");
}
WrappedConnection unlycon = (WrappedConnection)con;
System.out.println(unlycon.getUnderlyingConnection()+"");
out.println(unlycon.getUnderlyingConnection()+"");
Connection con1 = ds.getConnection();
WrappedConnection unlycon1 = (WrappedConnection)con1;
System.out.println("unlycon1 Connection : "+unlycon1.getUnderlyingConnection()+"");
out.println("unlycon1 Connection : "+unlycon1.getUnderlyingConnection()+"");
System.out.println("Second Connection : "+con1);
out.println("Second Connection : "+con1);
con.close();
con1.close();
%>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056337#4056337
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056337
More information about the jboss-user
mailing list