Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package appemp;
- import java.sql.*;
- /**
- *
- * @author stud
- */
- public class AppEmp {
- private Connection conn=null;
- private ResultSet rs=null;
- public boolean conectare_mySql(String IP, String dbName, String user, String password) {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection("jdbc:mysql://"+IP+"/"+dbName+"?" + "user="+user+ "&password="+password);
- System.out.println("Connection succesfull");
- return true;
- } catch(Exception ex) {
- ex.printStackTrace();
- return false;
- }
- }
- public static void main(String[] args) {
- AppEmp app=new AppEmp();
- app.conectare_mySql("10.10.16.30","employees","admin","admin");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement