title: connecting to sql database in java
body: <p>I am trying to connect to a database. My friend wrote this code but isn't working. It is not showing any errors.</p>
  
  <p>The name of the database is testdb and table name is tab. It is in the same folder where the code is.</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  public class dbtest {
   public static void main(String[] args){
      try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          Connection con = DriverManager.getConnection("jdbc:odbc:testdb");
          Statement stat = con.createStatement();
      stat.executeQuery("insert into tab values ('test','test','test')");
          //stat.executeUpdate();
      } catch (SQLException ex) {
          Logger.getLogger(dbtest.class.getName()).log(Level.SEVERE, null, ex);
      } catch (ClassNotFoundException ex) {
          Logger.getLogger(dbtest.class.getName()).log(Level.SEVERE, null, ex);
      }
      }
  }
  </code></pre>