Java 连oracle 12C 起步

package javaapplication2;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JavaApplication2 {
    
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        String url="jdbc:oracle:thin:@//10.98.0.62:1521/wdpis";
        Connection conn=DriverManager.getConnection(url,"qu","query");
        Statement stmt=conn.createStatement();
        
        ResultSet rs=stmt.executeQuery("select item_no,batch_no,seq_no from dt_out_att ");
        while(rs.next()){
            System.out.print("Item_NO:"+rs.getString("item_no"));
            System.out.print("Batch_NO:"+rs.getString("batch_no"));
            System.out.println("Seq_NO:"+rs.getString("seq_no"));
        }
        rs.close();
        stmt.close();
        conn.close();
    }
    
}

 

posted @ 2015-11-30 11:08  蕭慶蘋  阅读(798)  评论(1编辑  收藏  举报