public static void main(String args[]) throws Exception
{
Connection conn = null;
OraclePreparedStatement stmt = null;
InputStream in = null;
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:ORa92", "xmldb", "xmldb");
in = new java.io.FileInputStream("D:\xmldir\po.xml");
String statment = "insert into tb_doc_table values(1,?)";
stmt = (OraclePreparedStatement)conn.prepareStatement(statment);
oracle.sql.CLOB clob = createCLOB(conn,in);
XMLType xt = XMLType.createXML(conn,clob);
stmt.setObject(1, xt);
int k = stmt.executeUpdate();
conn.commit();
System.out.println(k);
}catch(SQLException e) {
int errorCode = e.getErrorCode();
System.out.println("ERROR_CODE = " + errorCode);
e.printStackTrace();
if(conn != null) { try{ conn.rollback(); }catch(Exception exc) { exc.printStackTrace(); } }
}finally{
if(stmt != null) { try{ stmt.close(); }catch(Exception exc) { exc.printStackTrace(); } }
if(conn != null) { try{ conn.close(); }catch(Exception exc) { exc.printStackTrace(); } }
}
}
***** 아름다운프로님에 의해서 게시물 복사 + 카테고리변경되었습니다 (2003-12-18 16:49)
{
Connection conn = null;
OraclePreparedStatement stmt = null;
InputStream in = null;
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:ORa92", "xmldb", "xmldb");
in = new java.io.FileInputStream("D:\xmldir\po.xml");
String statment = "insert into tb_doc_table values(1,?)";
stmt = (OraclePreparedStatement)conn.prepareStatement(statment);
oracle.sql.CLOB clob = createCLOB(conn,in);
XMLType xt = XMLType.createXML(conn,clob);
stmt.setObject(1, xt);
int k = stmt.executeUpdate();
conn.commit();
System.out.println(k);
}catch(SQLException e) {
int errorCode = e.getErrorCode();
System.out.println("ERROR_CODE = " + errorCode);
e.printStackTrace();
if(conn != null) { try{ conn.rollback(); }catch(Exception exc) { exc.printStackTrace(); } }
}finally{
if(stmt != null) { try{ stmt.close(); }catch(Exception exc) { exc.printStackTrace(); } }
if(conn != null) { try{ conn.close(); }catch(Exception exc) { exc.printStackTrace(); } }
}
}
***** 아름다운프로님에 의해서 게시물 복사 + 카테고리변경되었습니다 (2003-12-18 16:49)