title: How to hide password to MySQL database from people using the program
body: <p>I created a java program with JDBC that successfully connects to my computer server's MySQL database like this:</p>
  
  <pre><code>    try
      {
          // The newInstance() call is a work around for some
          // broken Java implementations
  
          Class.forName("com.mysql.jdbc.Driver").newInstance();
      }
      catch (Exception ex)
      {
          // handle the error
      }
  
      try
      {
          conn = DriverManager.getConnection(("jdbc:mysql://191.168.1.15:3306/databasename"), "username", "password");
  
          // Do something with the Connection
      }
      catch (SQLException ex)
      {
          // handle any errors
          System.out.println("SQLException: " + ex.getMessage());
          System.out.println("SQLState: " + ex.getSQLState());
          System.out.println("VendorError: " + ex.getErrorCode());
      }
  </code></pre>
  
  <p>However, if someone who wanted to figure out the password, it would be very simple with any java decompiler. How would I be able to prevent them from finding the password, or username even, for that matter?</p>