mysql> create table tablename(字段1 字段类型(字段长度),.....);
字段类型为double , int , float 时不用加字段长度。
下面是自动注册一个数据库表并生成数据库表的代码:
public int add(User u) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
String sql1 = "insert into user values('"+u.getName()+"','"+u.getPassword()+"',"+u.getAge()+")";
System.out.println(u.getName() + " "+ u.getPassword() + " "+ u.getAge());
DataBase bs = new DataBase();
System.out.println("更新到userDaoimpl");
int result = bs.upData(sql1);
sql1 = "create table `"+u.getName()+"`"+" (pname varchar(10), pdetial varchar(10),"+"price double,pnumber double);";
//DataBase bs2 = new DataBase();
bs.upData(sql1);
bs.close();
return result;
}