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.SQLException;
- public class ConexaoBD {
- // Define o Metodo de Conexao quando a classe � chamada
- static {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
- public Connection obtemConexao() throws SQLException{
- System.getProperties().setProperty("javax.net.ssl.trustStore","/mysqlcertificate.pem");
- return DriverManager.getConnection(
- "jdbc:mysql://myHost",
- "myUsername",
- "myPassword");
- }
- }
- Connection conn = null;
- Statement stm = null;
- try {
- ConexaoBD bd = new ConexaoBD();
- conn = bd.obtemConexao();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement