Reputation: 1813
I am doing a project in javafx using netbeans 7.4. I need to establish a connection with MySQL database. What are the steps for that ?
Upvotes: 1
Views: 774
Reputation: 701
In a Java project with netbeans i use this(local database):
String url = "jdbc:derby://localhost:1527/Database";
try{Class.forName("org.apache.derby.jdbc.ClientDriver"); //... set the driver
con = DriverManager.getConnection(url,"username","password");
stmt = con.createStatement();
System.out.println("Connected!");
}catch(Exception q){System.out.println("Not connected!");
The url can be found in database property, the driver too
Upvotes: 1