import java.net.URL;
import java.sql.*;
public class JavaOracle {
public JavaOracle() {
}
public static void main(String[] args){
try
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print(e.getMessage());
}
String url="jdbc:oracle:thin:@Server:1521:SDCDB";
Connection conn=DriverManager.getConnection(url,"test","test");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select score from MY");
while(rs.next())
{
System.out.println(rs.getString(1));
}
conn.close();
}
catch(SQLException ex)
{
while(ex!=null)
{System.out.println(ex.getSQLState());
}
}
}
}
本文地址:http://com.8s8s.com/it/it14700.htm