package br.com.rosanelliweb.classes;
import java.sql.*;
public class Conexao {
private static String _connectionString;
private static Connection _conexao;
public static void Conectar() throws SQLException, ClassNotFoundException {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
_connectionString = "jdbc:sqlserver://localhost:1433;databaseName=Login;user=sa;password=sqlsdk8;";
_conexao = DriverManager.getConnection(_connectionString);
}
public static ResultSet executaconsulta(String query) throws SQLException {
Statement st = _conexao.createStatement();
ResultSet resultado = st.executeQuery(query);
return resultado;
}
public static void executaUpdate(String query) throws SQLException {
Statement st = _conexao.createStatement();
st.executeUpdate(query);
}
public static void fechaConexao() throws SQLException {
_conexao.close();
}
}
Nenhum comentário:
Postar um comentário