JAVA向数据库添加数据 有一个问题 大家帮忙看看! 谢谢了
package lch;import java.sql.*;
public class tianjiaguanliyuan
{
public static Connection conn;
public static Statement stmtl;
public static ResultSet rs=null;
public static final String ACS_CON_STR="sun.jdbc.odbc.JdbcOdbcDriver";
public static PreparedStatement ps;
public static Connection getConnect(String url)
{
Connection conn=null;
try
{
Class.forName(ACS_CON_STR);
conn=DriverManager.getConnection(url);
}
catch(Exception e)
{
e.printStackTrace();
}
return conn;
}
public static boolean disconnect()
{
boolean successed=false;
try{
if(conn!=null) conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return successed;
}
public static void prepareStatement1()
{
String sql = "insert into dl values (gg,123)";
PreparedStatement ps;
try{
ps=conn.prepareStatement(sql);
ps.setString(2,"sql");
ps.executeUpdate();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static boolean CloseResltSet()
{
boolean successed=false;
try{
if(rs!=null) rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return successed;
}
public static void main(String[] args)
{
//String mm="insert into dl values (gg,123)";
getConnect("jdbc:odbc:library");
prepareStatement1();
}
}