Computer Science, asked by science8860, 1 year ago

How to send textfield, combo box data from netbeans to mysql?

Answers

Answered by choudhary21
3
✔️✔️✔️<b><u> Hi Mate✔️✔️✔️✔️

Correct Answer

texfield, the combobox will have all values starting with a. 

Command✔️✔️✔️


private void FillCombo(){
String url = "jdbc:mysql://localhost:3306/pharmacy";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "test";
String sql = "select medicinename from medicine where medicinename like '%"+jTextField5.getText()+"%'";

try{

Class.forName(driver).newInstance();
System.out.println("1");
Connection con = (Connection)DriverManager.getConnection(url,user,pass);
System.out.println("Connected");
Statement st=(Statement) con.createStatement();
PreparedStatement pst = con.prepareStatement(sql);
ResultSet rs = pst.executeQuery();
while(rs.next()){
String name = rs.getString("medicinename");
jComboBox1.addItem(name);

}

} catch(Exception e){
JOptionPane.showMessageDialog(null, e);

}}

 \huge{\bf{ \blue {\fbox{\underline{ \color{red}{THANKS}}}}}}
Similar questions