Dear all,
i have made a code for login form and i have input details to mysql database manually, and now i want to access it in my form...
also i want to insert data as well.
this is my code,
and when i execute it, it will gives a message connection established.
and directly jump to error message and says "Before start of result set".
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
public class VisaDocs {
public static void main(String[] args) {
Connection conx = null;
Statement stmt = null;
ResultSet rs = null;
String URL = "jdbc:mysql://localhost:3306/entry";
String db ="entry";
String u_name = "root";
String u_pwd="";
String query ="select * from users";
try{
conx = DriverManager.getConnection(URL,u_name,u_pwd);
if(conx!= null){
JOptionPane.showMessageDialog(null,"Connection has established","I N F O",JOptionPane.INFORMATION_MESSAGE);
stmt = conx.prepareStatement(query);
rs = stmt.executeQuery(query);
String u_1name = rs.getString("username");
String u_2name = rs.getString("password");
JOptionPane.showMessageDialog(null,u_1name,"This is supposed to be the MessageBox title.",JOptionPane.INFORMATION_MESSAGE);
}}
catch(Exception ex){
JOptionPane.showMessageDialog(null,ex.getMessage(),"E R R O R",JOptionPane.ERROR_MESSAGE);
}
finally{
try{
conx.close();
}catch(Exception ex){
JOptionPane.showMessageDialog(null,ex.getMessage(),"closing err",JOptionPane.ERROR_MESSAGE);
}
}
also how do i show selected data in a message box.
ex : (null,'"+u_1name+"'"+u_2name+"',"This is supposed")
is it like this or any other way....