请问各位,

java_jin 2002-07-01 10:54:46
我在工程java_jin里建的BatchUpdate文件,显示以下错误!!!!
java.lang.AbstractMethodError

at java_jin.BatchUpdate.main(BatchUpdate.java:34)

Exception in thread "main"
...全文
43 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
java_jin 2002-07-01
  • 打赏
  • 举报
回复
就是连接数据的方法呀,代码如下,

package java_jin;
import java.sql.*;
public class BatchUpdate
{
public static void main(String args[]) throws SQLException
{
ResultSet rs=null;
PreparedStatement ps=null;
String url="jdbc:oracle:thin:@195.100.130.55:1521:ora";
Connection con;
Statement stmt;
//加载数据库驱动
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
}catch(java.lang.ClassNotFoundException e)
{
System.err.print("ClassNotFound Exception:");
System.err.println(e.getMessage());
}
try{
con=DriverManager.getConnection(url,"hr","hr");
//提交连接请求
con.setAutoCommit(false);
stmt=con.createStatement();
stmt.addBatch("insert into table_1 values(1,'新概念1')");
stmt.addBatch("insert into table_1 values(2,'新概念2')");
stmt.addBatch("insert into table_1 values(3,'新概念3')");
int[] updateCounts=stmt.executeBatch();
con.commit();
con.setAutoCommit(true);
ResultSet uprs=stmt.executeQuery("select * from table_1");
while(uprs.next())
{
int id=uprs.getInt("id");
String xx=uprs.getString("name");
System.out.println(id +" "+ xx);
}
uprs.close();
stmt.close();
con.close();
}
catch(BatchUpdateException b)
{
System.err.println("--BatchUpdateException---");
System.err.println("SQLState:"+b.getSQLState());
System.err.println("Message:"+b.getMessage());
System.err.println("Vendor:"+b.getErrorCode());
System.err.println("Update Counts:");
int[] updateCounts=b.getUpdateCounts();
for(int i=0;i<updateCounts[i];i++)
{
System.err.print(updateCounts[i]+" ");
}
System.err.println(" ");
}
catch(SQLException ex)
{
System.err.println("--SQLException---");
System.err.println("SQLState:"+ex.getSQLState());
System.err.println("Message:"+ex.getMessage());
System.err.println("Vendor:"+ex.getErrorCode());
}
}
}
wjmmml 2002-07-01
  • 打赏
  • 举报
回复
你是不是实例化了一个抽象的方法,在main方法里面。

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧