WEB开发网
开发学院数据库DB2 我与Db2 9新特性的零距离体验 阅读

我与Db2 9新特性的零距离体验

 2007-11-02 21:41:26 来源:WEB开发网   
核心提示: 查询操作 查询xml(标准化越来越近了)字段的类为readxml(标准化越来越近了).java,该类通过提供cid来查询客户表中的info字段并产生xml(标准化越来越近了)文件,我与Db2 9新特性的零距离体验(4), package xml(标准化越来越近了);import java.io.Buffere
   查询操作
   查询xml(标准化越来越近了)字段的类为readxml(标准化越来越近了).java,该类通过提供cid来查询客户表中的info字段并产生xml(标准化越来越近了)文件。
package xml(标准化越来越近了);import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStreamReader;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.util.Properties;public class readxml(标准化越来越近了) ...{private static Connection conn;static Properties db2ConnProps = new Properties();private static PreparedStatement poStmt;private static ResultSet rs;static Properties fileinputProps = new Properties();public static void main(String[] args) throws FileNotFoundException,IOException, SQLException ...{String db, userName, passwd, host, port,description;host = port = db = userName = passwd = null;/**//* load the contents of properties file in case of missing arguments*/db2ConnProps.load(new FileInputStream("F:\\eclipse\\WorkPlace\\DB2xml(标准化越来越近了)\\src\\db2Conn.properties"));db = db2ConnProps.getProperty("databaseName");userName = db2ConnProps.getProperty("userName");passwd = db2ConnProps.getProperty("password");host = db2ConnProps.getProperty("hostName");port = db2ConnProps.getProperty("portNumber");/**//** connect to the database **/conn = db2Conn.get(db, userName, passwd, host, port);int id = 99;String fn = "F:\\eclipse\\WorkPlace\\DB2xml(标准化越来越近了)\\src\\Client8877.xml(标准化越来越近了)";String sqls = "insert into customer ( cid, info) values (?, ?)";File file = new File(fn);try ...{System.out.print(getDescription("88"));} catch (RuntimeException e) ...{// TODO Auto-generated catch block e.printStackTrace();} finally ...{conn.close();}}public static String getDescription(String cid)...{String description;description=null; try...{poStmt = conn.prepareStatement("Select INFO from CUSTOMER where cid=?");poStmt.setString(1,cid);rs= poStmt.executeQuery();if(rs.next())...{description=rs.getString(1);}elseSystem.out.println(" Customer info not found.\n");}catch(SQLException sqle)...{System.out.println("Error Msg: "+ sqle.getMessage());System.out.println("SQLState: "+sqle.getSQLState());System.out.println("SQLError: "+sqle.getErrorCode());System.out.println("Rollback the transaction and quit the program");System.out.println();try ...{conn.setAutoCommit(false);}catch (java.sql.SQLException e)...{e.printStackTrace();System.exit(-1);}try ...{ conn.rollback(); }catch (Exception e)...{JdbcException jdbcExc = new JdbcException(e, conn);jdbcExc.handle();}System.exit(1);}return description;}} 

我与Db2 9新特性的零距离体验(图二)

打开: http://www.cncms.com.cn/db2/y372916.html

上一页  1 2 3 4 5 6  下一页

Tags:我与 Db 特性

编辑录入:coldstar [复制链接] [打 印]
赞助商链接