Thu Jan 31, 2013 11:23 pm
/*
* MyComboBox.java
*
*/
package connectingdatabase.Search;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JComboBox;
/**
*
* @author sami
*/
class MyComboBox extends JComboBox
{
public MyComboBox(Connection conn,String TableName)
{
if(conn==null) {
return;
}
Statement stat;
try {
stat = conn.createStatement();
ResultSet rs=stat.executeQuery("Select * from "+TableName+"; ");
ResultSetMetaData rsmd= rs.getMetaData();
int size=rsmd.getColumnCount();
for(int i=0;i<size;i++)
{
addItem(rsmd.getColumnName(i+1));
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.