Witam,
mam problem z podłączeniem do bazy danych. Chcę się do niej podłączyć z Servleta za pomocą Beana.
KOD BEANA
package fasolki;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
/**
* Session Bean implementation class HelloWorld
*/
@Stateless
public class HelloWorld implements HelloWorldRemote {
private java.sql.Connection polaczenie;
public String dodajDoBazy(String data, String godzina, String spotkanieZ) {
try {
polaczenie = DriverManager.getConnection("jdbc:mysql://localhost/terminarz", "szymon", "haslo123");
String zapytanie = "Insert into spotkania(Data,Godzina,SpotkanieZ,Zanotowano)"+"VALUES('"+data+"','"+godzina+"','"+spotkanieZ+"', CURDATE())";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
if (!polaczenie.isClosed()) {
java.sql.Statement st = polaczenie.createStatement();
st.execute(zapytanie);
return "Successfully connected to " + "MySQL server using TCP/IP...";
}
} catch (Exception e) {
return "Exception: " + e.getMessage();
} finally {
try {
if (polaczenie != null) {
polaczenie.close();
}
} catch (SQLException e) {
}
}
} catch(SQLException ex) {
return ex.toString();
}
return "Lipa";
}
i wyświetla mi taki komunikat java.sql.SQLException: No suitable driver found for jdbc//localhost/terminarz
Ma ktoś jakiś pomysł dlaczego tak się dzieje?