Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dbConnection;
- import java.sql.*;
- public class DBConnect {
- private Connection con;
- private Statement st;
- private ResultSet result;
- public ResultSet getResult() {
- return result;
- }
- public DBConnect() {
- String url = "jdbc:mysql://localhost:3306/mtis";
- String user = "root";
- String password = "";
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con = DriverManager.getConnection(url, user, password);
- st = con.createStatement();
- } catch(Exception e) {
- System.out.println("Error: " + e);
- }
- }
- public void getCodigoPostal(String cp) {
- try {
- String query = "select * from codigospostales where codigoPostal=" + cp;
- result = st.executeQuery(query);
- } catch(Exception e) {
- System.out.println("Error: " + e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement