-1

I want to build a simple login/register Java application using NetBeans 12.3 and I don't know how can I use the data in a table that I have created in MySQL database (login table contains two columns username/password).

In fact I connected MySQL database to NetBeans 12.3 using the services-->database-->right click new connection and picked the MySQL connector Java that I downloaded previously and it said that the connection worked. But I don't get it how can I use the data in that table in my program should I write some code specific to get the data inside my classes and use it.

enter image description here enter image description here

John Conde
  • 217,595
  • 99
  • 455
  • 496
Oussama
  • 11
  • 2
  • Of course you need to write code if you want your application accesses to the database. Netbeans just provides you the admin console to manage the database. – Franz Wong May 01 '21 at 06:14

1 Answers1

0

You can connect using normal JDBC.

   try{  
Class.forName("com.mysql.jdbc.Driver");  
Connection con=DriverManager.getConnection("url","username","password");  

Statement stmt=con.createStatement();  
ResultSet rs=stmt.executeQuery("Query");  
while(rs.next())  
System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));  
con.close();  
}catch(Exception e){ System.out.println(e);} 

Please let me know if you are facing any different issue. regards, Vishal