標籤:
package javaapplication2;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.PreparedStatement;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"); PreparedStatement pst=conn.prepareStatement("select item_no,batch_no,seq_no from dt_out_att "); ResultSet rs=pst.executeQuery(); 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(); pst.close(); conn.close(); } }
Java 連oracle 12C 起步_PreparedStatement