title: And Again... MySQL Embedded in Java App
body: <p>There are a lot of questions: "How to start working with MySQL as an embedded database?", "How to use Connector/MXJ", etc. But there is no any useful information (neither tutorials!). I mean there is no detailed instructions how to do such things. Of course, there is a MySQL website, where is an article about using MysqldResource. Actually, I don't understand what it is.</p>
  
  <p>Let's finish this lack of any restraint! Please, if you are experienced in this topic, give as full instruction as you can! (what to download, how to add jars(say, to eclipse), some code will be great...)</p>
  
  <p>For example, the following code doesn't work - <code>ClassNotFoundException</code>- though I have added <code>mysql-connector-mxj-gpl-5-0-11.jar</code> and <code>mysql-connector-mxj-gpl-5-0-11-bd-files.jar</code> to the project classpath.</p>
  
  <pre><code> import java.sql.Connection;
   import java.sql.DriverManager;
   import java.sql.ResultSet;
   import java.sql.SQLException;
   import java.sql.Statement;
  
  
    public class DatabaseWorks {
  
  public static void main(String[] args) {
      try {
          Class.forName("com.mysql.jdbc.Driver");
  
          try {
              Connection con = DriverManager.getConnection("jdbc:mysql://localhost", "root", "");
              Statement st = con.createStatement();
              String query = "SELECT VERSION();";
              ResultSet rs = st.executeQuery(query);
              rs.next();
              System.out.println("success!!!! " + rs.getString(1));
          } catch (SQLException e) {
              e.printStackTrace();
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  }
  </code></pre>