-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectTest.java
More file actions
41 lines (33 loc) · 1.01 KB
/
Copy pathSelectTest.java
File metadata and controls
41 lines (33 loc) · 1.01 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
40
41
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class SelectTest {
public static void main(String[] args) {
try
{
System.out.println("");
DriverManager.registerDriver(new org.hsqldb.jdbc.JDBCDriver());
System.out.println("driver registered");
Connection con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/xdb", "SA", "");
Statement statement = con.createStatement();
System.out.println("statement created");
ResultSet rs = statement.executeQuery("select * from employee");
while(rs.next())
{
System.out.println("Emp no: "+rs.getInt(1));
System.out.println("Emp name: "+rs.getString(2));
System.out.println("Emp salary: "+rs.getInt(3));
System.out.println("----------------------");
}
rs.close();
statement.close();
con.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}