import java.sql.*;
  class Connsql
  {
   public static void main(String[] args) {
      Connection connection = null ;
try
{
//连接数据库
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); 
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jiqing"; 
String user="sa"; 
String password="111"; 
Connection conn= DriverManager.getConnection(url,user,password);  ResultSet  rs=null;//定义对象
Statement  stmt=conn.createStatement();//定义对表的处理方式
String sql="delete from linshi";
                         stmt.executeUpdate(sql);
//读取数据            rs.getString("Dsttermid")
          } catch(ClassNotFoundException e1) { //catch could not find database driver exception. } catch(SQLException e2) { //catch could not connect to the database exception. }
}
}
这个是我能用的代码,你看看能用吗