-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateStudentTable.java
More file actions
39 lines (32 loc) · 1.22 KB
/
CreateStudentTable.java
File metadata and controls
39 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package TeacherRegister;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class CreateStudentTable {
public static void createNewTable() throws ClassNotFoundException {
// SQLite connection string
String url = "jdbc:sqlite:C://sqlite/SSSIT.db";
// SQL statement for creating a new table
String sql = "CREATE TABLE IF NOT EXISTS Marks (\n"
+ " RollNo integer PRIMARY KEY,\n"
+ " Name text NOT NULL,\n"
+ " Marks integer\n"
+ ");";
try{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
stmt.execute(sql);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
/**
* @param args the command line arguments
* @throws ClassNotFoundException
*/
public static void main(String[] args) throws ClassNotFoundException {
createNewTable();
}
}