【发布时间】:2019-12-04 10:07:39
【问题描述】:
我正在尝试解决我的错误,但我经常看到此错误。帮我解决。
public static void fetchDetails() throws SQLException
{
int i;
Scanner scann = new Scanner(System.in);
Connection c = DriverManager.getConnection("jdbc:derby://localhost:1527/AttendClass","ms","6079");
Statement st = c.createStatement();
System.out.println("\n1.Civil\n2.CSE\n3.ECE\n4.EEE\n4.ICE\n5.IT\n6.MECH\n7.MBA\nChoose Your Department: ");
ch = scann.nextInt();
switch(ch)
{
case 1:
dept = "CIVIL";
String tbl1 = "CREATE TABLE "+dept+"(bno int NOT NULL AUTO_INCREMENT,one varchar(30),two varchar(30),three varchar(30),four varchar(30),five varchar(30),six varchar(30),seven varchar(30),eight varchar(30)),PRIMARY KEY (bno)";
st.executeUpdate(tbl1);
ResultSet rs = st.executeQuery("select * from "+dept+"");
System.out.println("Enter the no. of students: ");
i = scann.nextInt();
我希望我的表自动递增的输出。
【问题讨论】:
-
As documented in the manual Derby 没有
auto_increment。改用标识列
标签: sql derby auto-increment identity-column