title: Connection methods to Google Cloud SQL Database with Java JDBC
body: <p>Currently, I have created a simple Java application that connects to my Google Cloud SQL database the <em>normal</em> way:</p>
  
  <pre><code>try {
     Class.forName("com.mysql.jdbc.Driver");
     Connection con = DriverManager.getConnection("jdbc:mysql://-google-cloud-sql-ip:-port-/-projectname-","-user-","-password-");
     Statement st = con.createStatement();
  }
  catch (Exception ex) {
     ex.printStackTrace();
  }
  </code></pre>
  
  <p>My only concern is that the password is placed here as plain text. It is not protected in any way. I do know that it is possible to protect the source code with something like <a href="http://www.yworks.com/en/products_yguard_about.html" rel="nofollow">yGuard</a>. Also, I have to register my external IP address in Google Cloud for it to work.</p>
  
  <p>Therefore, I was wondering if I could use some sort of OAuth method to make a database connection to the Cloud SQL database. I'd prefer a connection method that is independent of my computer's physical location, so I can connect anywhere I want (if I have an internet connection).</p>
  
  <p>Is there a better method than the one presented above, or is this the only way? And if so, please let me know how to protect the plain text password.</p>
  
  <p>Any help is much appreciated!</p>