|
楼主 |
发表于 2004-12-7 11:06:14
|
显示全部楼层
test.java代码
package book;
import java.util.*;
import java.io.*;
import java.sql.*;
public class test implements Serializable{
private Connection connect;
private Vector v=new Vector();
public Vector getname(){
try{
Class.forName("org.gjt.mm.mysql.Driver");
System.out.println("OK,!!!!!!!");
}
catch(Exception e){
System.out.println("Error Loading Mysql");
e.printStackTrace();
}
try{
Connection connect=DriverManager.getConnection("jdbc:mysql://localhost/book_shop","root","");
System.out.println("bbbbbbbbbbbbbbbbb");
Statement stmt=connect.createStatement();
ResultSet rs=stmt.executeQuery("select book_name,price,save_count from books where up_tag=1");
while(rs.next()){
v.addElement(rs.getString("book_name"));
}
}
catch(Exception e){
System.out.println("get data error");
e.printStackTrace();
}
return v;
}
protected void finalize(){
try{
connect.close();
}
catch(SQLException sqlException){
sqlException.printStackTrace();
}
}
} |
|