连接数据库的疑惑

05-04-28 flyingshadow

下面是我的代码:

我在jbuilder里写的一个javabean程序在连接数据库是出错请高手指点

package untitled5;

import java.io.*;

import java.sql.*;

public class Bean1 extends Thread{

String c1;

String c2;

Connection con;

public void go() {

Bean1 single = new Bean1();

single.start();}

public void run() {

//String conne="";

try {

Class.forName("org.postgresql.Driver").newInstance();

}

catch (ClassNotFoundException ex1) {

}

catch (IllegalAccessException ex1) {

}

catch (InstantiationException ex1) {

}

try{

con = DriverManager.getConnection("jdbc:postgresql:globus4401",

"postgres", "");

for (; ; ) {

try {

Runtime rt = Runtime.getRuntime();

Process proc = rt.exec("top -n 1 >/root/jiankong/2.txt");

BufferedReader br = new BufferedReader(new FileReader("/root/jiankong/2.txt"));

br.readLine();

br.readLine();

String s1 = br.readLine();

String s2 = br.readLine();

int n1 = s1.indexOf("id", 40);

String s11 = s1.substring(n1 - 7, n1);

int n2 = s2.indexOf("free", 25);

String s22 = s2.substring(n2 - 9, n2);

this.c1 = s11;

this.c2 = s22;

}

catch (IOException e) {

System.err.println("error:" + e);

}

Statement s = con.createStatement();

String r1 = "update tmpservice set cpu='"+ c1 +"',memory='"+c2+"'";

s.executeUpdate(r1);

s.close();

con.close();

try {

Thread.sleep(5 * 1000);

}

catch (InterruptedException ex) {

System.err.println("error:"+ ex);

}

}

}

catch (SQLException e) {

System.out.println("SQLEexption:" + e.getMessage());

}

}

public String getC1() {

return c1;

}

public void setC1(String c1) {

this.c1 = c1;

}

public String getC2() {

return c2;

}

public void setC2(String c2) {

this.c2 = c2;

}

public Bean1() {

}

}

下面是错误信息:

SQLEexption:No suitable driver

SportsBaby1980
2005-04-28 22:46

调试都不会?