Skip to content

Instantly share code, notes, and snippets.

@lubarinobr
Created March 2, 2019 02:26
Show Gist options
  • Save lubarinobr/0530dc68cece40aa21f9fea159626ad2 to your computer and use it in GitHub Desktop.
Save lubarinobr/0530dc68cece40aa21f9fea159626ad2 to your computer and use it in GitHub Desktop.
package br.com.lubarino.profiles.conexao;
import org.springframework.beans.factory.annotation.Value;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JDBCConnection {
@Value("${database.url}")
private String url;
@Value("${database.username}")
private String username;
@Value("${database.password}")
private String password;
public Connection connect() throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(url,username, password);
return connection;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment