Re: Loading XML into database [message #91099] |
Thu, 04 April 2002 20:58 |
Sunil Dua
Messages: 1 Registered: April 2002
|
Junior Member |
|
|
Here below is the program which runs well. Hope it will help:
import java.sql.*;
import oracle.xml.sql.query.OracleXMLQuery;
import oracle.xml.sql.dml.OracleXMLSave;
import java.io.*;
public class testInsert
{
public static void main(String argv[[]]) throws SQLException
{
Connection conn = getConnection("law1","law1");
OracleXMLQuery qry = new OracleXMLQuery(conn,"SELECT name as T, Reptype as C FROM Key_reptype");
String str = qry.getXMLString();
try{
OracleXMLSave sav = new OracleXMLSave(conn, "law1.titles");
sav.insertXML(str);
sav.close();
}catch(Exception ex){System.out.println(ex.toString());}
}
private static Connection getConnection(String username, String password)
throws SQLException
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@portal:1521:star", username,password);
return conn;
}
}
|
|
|