[英]Establish MySQL database connection from netbeans 7.4
I am doing a project in javafx using netbeans 7.4. 我正在使用netbeans 7.4在javafx中进行项目。 I need to establish a connection with MySQL database. 我需要与MySQL数据库建立连接。 What are the steps for that ? 有哪些步骤?
In a Java project with netbeans i use this(local database): 在带有netbeans的Java项目中,我使用以下(本地数据库):
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 网址也可以在数据库属性中找到,驱动程序也可以找到
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.