insert操作在initStore方法里。
stmt = con.createStatement();
String sql = "insert into store (id) value (" + "'"+i+"')";;
stmt.executeUpdate(sql);
这里是jdbc的文档
</pre><pre name="code" class="java"><pre name="code" class="java">package pro1;
import java.sql.*;
public class Gradation
{
private static final String PreparedStatement = null;
/**
* @param args
*/
public static void main(String[] args)
{
Gradation g = new Gradation();
g.getCon();
g.initStore();
g.showInfo();
}
static Connection con;
static Statement stmt;
static ResultSet res;
public void getCon(){
con = ConnectionClass.getConnection();
}
public void showInfo()
{
try
{
stmt = con.createStatement();
res = stmt.executeQuery("select * from store");
while (res.next())
{
String id = res.getString("id");
String pwd = res.getString("pwd");
String isStore = res.getString("isStore");
System.out.println(id + " " + pwd + " " + isStore);
}
} catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void initStore()
{
try
{
for(int i=1;i<=15;i++)
{
stmt = con.createStatement();
String sql = "insert into store (id) value (" + "'"+i+"')";;
stmt.executeUpdate(sql);
}
} catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}