java连接oracle报错:java.sql.SQLException: ORA-04031: unable to allocate 4200 bytes of shared memory ("shared pool","unknown obje

dodorunning 2006-10-24 09:25:54
我需要将oracle表中的数据导入到sql server表中,运行如下程序一段时间后,报错:java
java.sql.SQLException: ORA-04031: unable to allocate 4200 bytes of shared memory ("shared pool","unknown object"

1.是否是oracle自身设置问题,比如说需要增加shared memory?
2.程序本身有问题?

public void run(){
System.out.print("Starting Service......");
//store the mobile infor
ArrayList mobile = new ArrayList();
//store the lingtong infor
ArrayList lingtong = new ArrayList();
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.1.3.38:1521:ORAZHFW", "pbmail", "pbmail");
conn.setAutoCommit(false);
//System.out.println("Connecting to the ora");
Statement statement =conn.createStatement();
//get the data from table
//mail_info_all
ResultSet results = statement.executeQuery ("select * from mail_info_all");

while (results.next ()){
String number = results.getString(1);
System.out.println("Tel: "+number);
String code = results.getString(2);
String date = results.getString(4);
String time = results.getString(5);
int money = results.getInt(6);
float fmoney =(float)money;
float rmoney = fmoney/100;
//System.out.println(code);
Sms sms = new Sms(number,code,date,time,rmoney);
if(code.equals("0001")||code.equals("0002")){
mobile.add(sms);
}else{
lingtong.add(sms);
}
}
results.close();
statement.close();
Statement delstatement = conn.createStatement();
int del=delstatement.executeUpdate("delete mail_info_all");
conn.commit();
System.out.println("Have delete "+del+" results.Haha.");
//close the database connection and relates
delstatement.close();
conn.close();
System.out.println("OK!");
}catch(SQLException e){
e.printStackTrace();
}
//Connet to the sqlserver db
try{
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
System.out.println("Can't find the db driver......");
e.printStackTrace();
}
String connectionUrl = "jdbc:sqlserver://10.62.0.44;database=POSTSMS";
Connection con = DriverManager.getConnection(connectionUrl,"sa","smsinfo");
System.out.println("sqlserver connect is ready......");
Sms smsend=null;
Iterator it = mobile.iterator();
while(it.hasNext()){
smsend=(Sms)(it.next());
//System.out.println(smsend.toContent());
CallableStatement stmt = con.prepareCall("{call up_SubmitSMSTest(?,?,?)}");
stmt.setString(1, "");
stmt.setString(2, smsend.getNumber());
stmt.setString(3,smsend.toContent());
stmt.execute();
//
stmt.close();
}
con.close();
}catch(SQLException e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}

}
...全文
735 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hbwhwang 2006-10-29
  • 打赏
  • 举报
回复
估计是过于频繁连接数据库造成的.
你用数据库连接池就应该没有这个问题了.
twenty_three 2006-10-26
  • 打赏
  • 举报
回复
解决方法见:http://dbanotes.net/Oracle/Ora-04031.htm
lianhg 2006-10-24
  • 打赏
  • 举报
回复
可能是程序频繁连接数据库造成的。
把 oracle 数据库 shutdown , 然后增大 init 文件中的 shared pool。

62,616

社区成员

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

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