Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import java.util.StringTokenizer;
- import java.util.logging.Logger;
- import com.google.appengine.api.utils.SystemProperty;
- import static com.google.appengine.api.utils.SystemProperty.environment;
- import static com.google.appengine.api.utils.SystemProperty.Environment.Value.Development;
- import static com.google.appengine.api.utils.SystemProperty.Environment.Value.Production;
- Connection con=null;
- SystemProperty.Environment.Value env = environment.value();
- if(env == Production)
- {
- System.out.println("Inside Production Phase");
- // Load the class that provides the new "jdbc:google:mysql://" prefix.
- Class.forName("com.mysql.jdbc.GoogleDriver");
- url = "jdbc:google:mysql://<my-project-id>:<cloud-sql-instance>/<database-name>?user=<user-name>&password=<database-password>&useUnicode=true&characterEncoding=UTF-8";
- }//if
- else if(env == Development)
- {
- System.out.println("Inside Development Phase");
- // This will load the MySQL driver, each DB has its own driver
- Class.forName("com.mysql.jdbc.Driver");
- url = "jdbc:mysql://127.0.0.1:3306/<database-name>?user=root";
- }//else if
- con = DriverManager.getConnection(url);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement