다음 코드에서 나는 적합한 드라이버가 없습니다. 오류 : 도와주세요. 나는 이미 한 시간 동안 그걸로 일해 왔고 어쩔 수 없다.mysql java 적절한 드라이버가 없습니다
미친입니다. 나는 GWT를 망치기 시작하기 전에이 정확한 발을 일찍 할 수 있었다.
package com.gwt.churchweb.churchweblogin.client;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.user.client.Window;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.DriverManager;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Login extends Composite {
public Login() {
VerticalPanel verticalPanel = new VerticalPanel();
initWidget(verticalPanel);
verticalPanel.setSize("329px", "186px");
Label lblNewLabel = new Label("Sign into your account");
lblNewLabel.setStyleName("gwt-Login-SigninLabel");
verticalPanel.add(lblNewLabel);
FlexTable flexTable = new FlexTable();
verticalPanel.add(flexTable);
flexTable.setWidth("308px");
Label lblNewLabel_1 = new Label("Username:");
lblNewLabel_1.setStyleName("gwt-Label-Login");
flexTable.setWidget(0, 0, lblNewLabel_1);
lblNewLabel_1.setWidth("72px");
final TextBox textboxUsername = new TextBox();
textboxUsername.setStyleName("gwt-LoginTextBox");
flexTable.setWidget(0, 1, textboxUsername);
textboxUsername.setWidth("204px");
Label lblNewLabel_2 = new Label("Password:");
lblNewLabel_2.setStyleName("gwt-Label-Login");
flexTable.setWidget(1, 0, lblNewLabel_2);
lblNewLabel_2.setWidth("66px");
final TextBox textBoxPassword = new TextBox();
textBoxPassword.setStyleName("gwt-LoginTextBox");
flexTable.setWidget(1, 1, textBoxPassword);
textBoxPassword.setWidth("204px");
flexTable.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
flexTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT);
CheckBox chckbxRememberMeOn = new CheckBox("Remember me on this computer");
chckbxRememberMeOn.setStyleName("gwt-Checkbox-Login");
flexTable.setWidget(2, 1, chckbxRememberMeOn);
Button btnSignIn = new Button("Sign In");
btnSignIn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Connection con = null;
Statement st = null;
ResultSet rs = null;
String url = "jdbc:mysql://localhost:3306/churchweb";
String user = "root";
String password = "*****";
try {
con = DriverManager.getConnection(url, user, password);
st = con.createStatement();
rs = st.executeQuery("SELECT VERSION()");
Window.alert("Fixing to try it");
if (rs.next()) {
Window.alert(rs.getString(1));
}
} catch (SQLException ex) {
Logger lgr = Logger.getLogger(Login.class.getName());
lgr.log(Level.SEVERE, ex.getMessage(), ex);
} finally {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (con != null) {
con.close();
}
} catch (SQLException ex) {
Logger lgr = Logger.getLogger(Login.class.getName());
lgr.log(Level.WARNING, ex.getMessage(), ex);
}
}
if (textboxUsername.getText().length() == 0
|| textBoxPassword.getText().length() == 0) {
Window.alert("Username or password is empty.");
}
}
});
btnSignIn.setStyleName("gwt-Login-SigninButton");
flexTable.setWidget(3, 1, btnSignIn);
}
}
이 문제를 해결하기 위해 이미 두 가지 답변이 제공되었다고 생각합니다. 드라이버를 어디에서로드하고 있습니까? 나는 당신의 코드 게시에서 이것을 보지 못한다. 이것은 jvm이 "적절한"드라이버를로드하도록 코드에서 수행되어야합니다. .jar 파일 만 있으면 문제가 해결되지 않습니다. – Freddy
String url = "jdbc : mysql : // localhost : 3306/churchweb"; String user = "root"; <==이게 운전수를로드하지 않습니까, 프레디? –