时间:2021-07-01 10:21:17 帮助过:3人阅读
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;
public class TestJDBC
{
public static void main(String[] args)
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");//连接oracle数据库管理器
conn = DriverManager.getConnection("jdbc:oracle:thin:@10.130.12.34:1521:easdb","kingdee75","kingdee");//连接数据库
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM T_BAS_USERDEFINEDDATA");
while(rs.next())
{
System.out.println(rs.getString("FNUMBER"));
}
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();//关闭回收资源
}
if(stmt != null)
{
stmt.close();
}
if(conn != null )
{
conn.close();
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}
结果可以在eclipse中看到。
JDBC
标签: