/*
忙了一下午,终于搞好了,我的mysql5.0是for windows
请先在my.ini这个文件里面吧default-character-set=gbk
再建库bo,表mo(id char(6))
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DbCon {
public static void main(String []argv)
{
try
{
Class.forName("org.gjt.mm.mysql.Driver");
System.out.println("Create Sucess!!");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/bo?user=root&password=nihaoma&useUnicode=true&characterEncoding=GBK");
System.out.println("Connect Sucess!!");
//ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE
Statement st=con.createStatement();
ResultSet su=st.executeQuery("select * from mo");
while (su!=null && su.next())
{
System.out.println(su.getString("id"));
}
st.execute("insert into mo values('人')");
//System.out.print(ne);
//System.out.println("end...");
}
catch(ClassNotFoundException e)
{
}
catch(SQLException e)
{
}
catch(Exception e)
{
}
}
}