?? jdbcsample.java
字號(hào):
import java.sql.*;
import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.table.AbstractTableModel;import java.awt.Dimension;
public class JDBCSample{
public static void main(String[] args){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){
System.out.println("Unable to load Driver Class");
return;
}
try{
Connection con = DriverManager.getConnection("jdbc:odbc:gold","root","luanluan");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select sid from student");
while(rs.next()){
System.out.println(rs.getString("sid"));
}
rs.close();
stmt.close();
con.close();
}
catch(SQLException se){
System.out.println("aaSQL exception: "+se.getMessage());
se.printStackTrace(System.out);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -