oke langsung aja. sesuai jdul, inilah class koneksi untuk netbeans dengan MySQL
jangan lupa ADD LIBRARY di dibagian libraries project, pilih MySQL JDBC Driver
package Application;
import java.sql.*;
public class Koneksi {
public Connection dbKoneksi;
public Statement statement;
public PreparedStatement prepareStatement;
public CallableStatement callableStatement;
public Koneksi() {
this.dbKoneksi = null;
}
public void bukaKoneksi() {
try {
/* utk ms-access
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dbKoneksi = DriverManager.getConnection("jdbc:odbc:kursus");
*/
Class.forName("com.mysql.jdbc.Driver");
dbKoneksi = DriverManager.getConnection
("jdbc:mysql://localhost:3306/bengkel","root", "likmi");
}
catch(Exception e){
e.printStackTrace();
}
}
public void tutupKoneksi(){
try {
if (statement != null)
statement.close();
if (prepareStatement != null)
prepareStatement.close();
if (dbKoneksi != null)
dbKoneksi.close();
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
}
Sekian dan Terimakasih