0
我寫了一個非常簡單的數據庫使用JDBC的JDBC查詢。 這裏是代碼eclipse不顯示任何輸出
import java.sql.*;
public class statement {
static final String JDBC_DRIVER="com.mysql.jdbc.Driver";
static final String URL="jdbc:mysql://localhost/emp";
static final String USER="root";
static final String PAS="1234";
public static void main(String [] args){
System.out.println("hello");
Connection con=null;
Statement stmt=null;
try{
System.out.println("creating database connection");
con=DriverManager.getConnection(URL,"root","1234");
String sql="update Employee set age 30 where id =103";
stmt=con.createStatement();
Boolean ret=stmt.execute(sql);
System.out.println("return value is: "+ret.toString());
int rows=stmt.executeUpdate(sql);
System.out.println("rows impacted: "+rows);
stmt.close();
con.close();
}catch(SQLException se)
{
System.out.println("hello");
}
}
}
在我的最後一個catch - 它只是檢查程序輸出任何東西。沒有錯誤,也沒有警告。但是,在我的控制檯窗口上,我收到
0 items
消息。問題是什麼?
p.s.我將所有的jar文件包含到我的項目中
你試過調試嗎?你不打印第一個「你好」嗎? – gonzo
打印'0項目'的代碼在哪裏? – dave
在控制檯上,根本沒有打印任何東西,那就是問題 –