连接oracle数据库,为什么报错java.lang.NullPointerException。
import java.sql.*;
class sql
{
private static Connection con=null;
private static Statement stmt=null;
private static ResultSet rs=null;
public static void main(String args[])
{
try
{
/* Test loading driver */
String driver = "oracle.jdbc.driver.OracleDriver";
System.out.println( "\n=> loading driver:" );
Class.forName( driver ).newInstance();
System.out.println( "OK" );
/* Test the connection */
String url = "jdbc:oracle:thin:@192.168.6.3:1521:JIVE";
con = DriverManager.getConnection(url, "system", "manager");
System.out.println( "\n=> connecting:" );
stmt=con.createStatement();
String sql = "select * from JIVEID";
String telphone = null;
while(rs.next())
{
telphone = rs.getString(1);
System.out.println(telphone);
}
con.close();
}
catch( Exception x )
{
System.err.println( x );
}
}
}
好像是在getConnection是有错,可是我的数据库密码和用户名都没有问题,为什么会这样?