为什么我的ECLIPSE 就是连接不上oracle 总是提示我空指针 不知道是哪里错误了??求大神告知!!
packageWL;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.State...
package WL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class 单个增删改 {
public static void main(String[] args) throws Exception {
//1.把Oracle数据库的一个驱动类加载到内存中
Class.forName("oracle.jdbc.driver.OracleDriver");
//2.得到连接对象(Connection)
String url = "jdbc:oracle:thin:@localhost:1521:XE";
Connection conn = DriverManager.getConnection(url,"zhangsan","123465");
//3.得到语句对象(Statement)
Statement st = conn.createStatement();
//4.准备好sql语句
//emp_seq是一个序列的名字
String str = "insert into emp(empno,ename,job,mgr,deptno) values(15,'xiaoqiang','程序员',2,20)";
//5.执行sql
st.executeUpdate(str);//这个方法可以执行单个增、删、改语句
//6.关闭资源
st.close();
conn.close();
}
}
Exception in thread "main" java.lang.NullPointerException
at java.lang.String.<init>(String.java:176)
at oracle.sql.CharacterSet.AL32UTF8ToString(CharacterSet.java:1517)
at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:589)
at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:542)
at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:821)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:362) 展开
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class 单个增删改 {
public static void main(String[] args) throws Exception {
//1.把Oracle数据库的一个驱动类加载到内存中
Class.forName("oracle.jdbc.driver.OracleDriver");
//2.得到连接对象(Connection)
String url = "jdbc:oracle:thin:@localhost:1521:XE";
Connection conn = DriverManager.getConnection(url,"zhangsan","123465");
//3.得到语句对象(Statement)
Statement st = conn.createStatement();
//4.准备好sql语句
//emp_seq是一个序列的名字
String str = "insert into emp(empno,ename,job,mgr,deptno) values(15,'xiaoqiang','程序员',2,20)";
//5.执行sql
st.executeUpdate(str);//这个方法可以执行单个增、删、改语句
//6.关闭资源
st.close();
conn.close();
}
}
Exception in thread "main" java.lang.NullPointerException
at java.lang.String.<init>(String.java:176)
at oracle.sql.CharacterSet.AL32UTF8ToString(CharacterSet.java:1517)
at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:589)
at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:542)
at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:821)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:362) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询