Witam,
Mam zainstalowany serwer krasnal ma swoim komputerze. Chcę pracować na bazie postawionej na tym serwerze. Napisałem taką klasę:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Oracle1;
import java.sql.*;
/**
*
* @author
*/
public class MySQL_p {
static class java {
public java() {
}
}
// fields
private Connection connection = null;
private Statement st = null;
private ResultSet rs = null;
private String driverName = null;
private String serverName = null;
private String dataBase = null;
private String userName = null;
private String password = null;
private String url = null;
// constructor
public MySQL_przemek() throws SQLException, InstantiationException, IllegalAccessException{
driverName = "org.gjt.mm.mysql.Driver";//"com.mysql.jdbc.Driver";//"sun.jdbc.odbc.JdbcOdbcDriver";//"org.gjt.mm.mysql.Driver";
serverName = "localhost:80";
dataBase = "pkp";
userName = "root";
password = "krasnal";
url = "jdbc:mysql://" + serverName + "/" + dataBase;
this.Connect();
}
// methods
private void Connect() throws SQLException, InstantiationException, IllegalAccessException
{
try{
Class.forName(this.driverName).newInstance();
this.connection = DriverManager.getConnection(url, userName, password);
this.st = this.connection.createStatement();
}
catch (ClassNotFoundException e) {
// Could not find the database driver
System.out.println("Brak polaczenia.\n Główny błąd: "+e.getMessage().toString());
System.out.println(url + userName + password);
}
}
public void Select_data() throws SQLException{
//this.Connect();
String querry = "SELECT imie FROM matka WHERE imie='Andrzej'";
rs = st.executeQuery(querry);
String name = rs.getString("imie");
System.out.print(name);
}
}
Podczas połączenia wywala mi wyjątek że brak połączenia. Czy wie ktoś jaki driverName muszę użyć do połączenia sięz bazą MySQL przez Krasnal Server?
pozdrawiam