我在oracle数据库有一个表,有两个字段,id和xml_c 分别为varchar2和xmltype类型,请问怎么编写程序应用jdbc从数据库中通过id查询到xml_c并且把它输出到指定的文件内,比如:c:/xml_out.xml
解决方案 »
- oracle视图创建
- ORA-01445: cannot select ROWID from, or sample, a join view without a key-preser
- oracle blob图片 增量抽取
- 请求一个统计的SQL.
- 存储过程与游标的问题
- Oracle函数的例子,把例子运行一遍,你会学到点东西哈!快乐就好!我刚边学边写的。
- linux下oracle9i创建数据库时出现的问题??
- 使用pl/sql Developer查询数时出错,怎么回事呀?
- 一个非常非常简单的问题?
- 数据库配置助手中出现问题!我填入新的sys,system口令确定后,出现"ORA-00988:缺少或无效口令错误..."
- IMP导入问题,000069,急!!!
- grant 如何给一个新建的用户赋权限 谢谢!!!!!!!!!!!!!!!!!!!!!!
{
try
{
// register the Oracle JDBC drivers
DriverManager.registerDriver(
new oracle.jdbc.OracleDriver()
);
// EDIT IF NECESSARY
// create a Connection object, and connect to the database
// as store using the Oracle JDBC Thin driver
myConnection = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:ORCL",
"scott",
"tiger"
);
// disable auto-commit mode
myConnection.setAutoCommit(false);
// create a Statement object
myStatement = myConnection.createStatement();
File file=new File("C:/xml_out.xml");
FileOutputStream fout=new FileOutputStream(file);
String mysql="select xml_c from myxml where id=?";
OraclePreparedStatement opst=(OraclePreparedStatement) myConnection.prepareStatement(mysql);
opst.setString(1,"20070622001");
OracleResultSet ors=(OracleResultSet)opst.executeQuery();
if(ors.next())
{
// get the XMLType
XMLType poxml = XMLType.createXML(ors.getOPAQUE(1));
// get the XMLDocument
Document podoc = (Document)poxml.getDOM();
// 这里有问题
((XmlDocument)podoc).write(fout);
//?????????????????????????????
}
ors.close();
System.out.println("xml文件已经读出到指定文件内!");
}
catch(Exception e)
{
System.out.println("error :"+e.toString() );
e.printStackTrace();
}
请高手补全程序,能够正确输出好吗?或者有更好的方法也行