title: How to change current database to another?
body: <p>I have a Java program connection to a MySQL database, how can I change the current database to a different one on the same connection?</p>
  
  <p>I connect to MySQL like this:</p>
  
  <pre><code>DriverManager.getConnection("jdbc:mysql://"+server+"/",log,pass);
  </code></pre>
  
  <p>After some operations I want to connect to a different mysql database on the same connection.  How can I do that?</p>
  
  <p>I tried to use:</p>
  
  <pre><code>Statement stat= con.createStatement();
  ResultSet r=stat.executeQuery("use mysql"); 
  </code></pre>
  
  <p>But that does not change the database to be used.  </p>