package com.globalite.dangdang.framework;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.sun.org.apache.xpath.internal.operations.String;
public class JDBCManager {
public static void main(String[] args) {
{
Connection ct=null;
Statement sm=null;
ResultSet rs ;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
ct = DriverManager.getConnection("jdbc:oracle:thin@127.0.0.1:1521:ORCL", "DangDang","Qweasd");
sm = ct.createStatement();
rs = sm.executeQuery("select id, name from book");
while (rs.next()) {
//用户名
System.out.println("用户名: "+rs.getString(1));
//默认是从1开始编号的
}
}
catch(SQLException e)
{
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
finally
{
}}
}
}
程序总是报错,“java.lang.NoSuchMethodError: main Exception in thread "main" ”。问题出在哪里?
答案:3 悬赏:20 手机版
解决时间 2021-02-24 19:17
- 提问者网友:星軌
- 2021-02-24 15:06
最佳答案
- 五星知识达人网友:西风乍起
- 2021-02-24 16:00
1)import com.sun.org.apache.xpath.internal.operations.String;
将上面这条import语句去掉。
2)ct = DriverManager.getConnection("jdbc:oracle:thin@127.0.0.1:1521:ORCL","DangDang","Qweasd");
改为
ct = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL","DangDang","Qweasd");
thin后面少了一个冒号
将上面这条import语句去掉。
2)ct = DriverManager.getConnection("jdbc:oracle:thin@127.0.0.1:1521:ORCL","DangDang","Qweasd");
改为
ct = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL","DangDang","Qweasd");
thin后面少了一个冒号
全部回答
- 1楼网友:污到你湿
- 2021-02-24 17:25
你的程序我运行通过了是环境变量设置的问题 classpath: .;c:\jsdk\lib\dt.jar;c:\jsdk\lib\tools.jar path: 原先的内容;c:\jsdk\bin
- 2楼网友:独行浪子会拥风
- 2021-02-24 17:05
删掉这句 import com.sun.org.apache.xpath.internal.operations.String;
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯