public void jComboBox_connect_mysql (){
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/sale?useUnicode=true&characterEncoding=big5";
String user = "testuser";
String password = "test623";
try {
conn = DriverManager.getConnection(url, user, password);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery( "SELECT * FROM tabaco_product " );
try{
while (rs.next()) {
jComboBox1.addItem(rs.getString("Tabaco_name"));
} // while
}catch(ArrayIndexOutOfBoundsException e){}
rs.close();
st.close();
conn.close();
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
2011年8月8日 星期一
訂閱:
張貼留言 (Atom)
0 意見:
張貼留言