Connecting java to database to make a login form
<p>Right now i'm making a kinda inventory database project. 
So i wanna ask what is the right way to connect java to database(mysql) in this case i use mysql that i installed from appserv and i manage it through phpmyadmin. and i'm using Netbeans IDE </p>

<p>so i surf the internet:</p>

<p>To Connect database :</p>

<ol>
<li>i add the jdbc library to my library</li>
<li>i made the new connection in netbeans (i already made database in mysql)</li>
<li>i fill my port etc</li>
</ol>

<p>To Test The Connection</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import java.sql.*;
public class connection {
    public static void main(String[]args){
   try {
    Class.forName("com.mysql.jdbc.Driver");
    System.out.println("Succeed Load Driver ..");
}catch (ClassNotFoundException ex ){
    System.out.println("error"+ex);
}
   try {
       String url = "jdbc:mysql://localhost:3306/data";
       Connection connect = DriverManager.getConnection(url,"root","password");
       System.out.println("Success Connect To Database");
   }catch(SQLException e){
       System.out.println("error"+e);
   }
         
}
}</code></pre>
</div>
</div>
</p>

<blockquote>
  <p>Question</p>
</blockquote>

<ol>
<li>is it the proper way to connect java to sql?</li>
<li>is it the proper way to test the connection?</li>
<li>I already design the login form ( jframe ) netbeans , the problem is how to get data from sql.so user can login but only for user that registered in the sql.  </li>
</ol>

<p>i'm just beginner 
sorry for my bad english anyway</p>