Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql java没有合适的驱动程序_Java_Mysql - Fatal编程技术网

mysql java没有合适的驱动程序

mysql java没有合适的驱动程序,java,mysql,Java,Mysql,在以下代码中..我没有得到合适的驱动程序..错误: 请帮忙。我已经用它工作了一个小时了,似乎想不出来 这太疯狂了。早在我开始玩弄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.g

在以下代码中..我没有得到合适的驱动程序..错误: 请帮忙。我已经用它工作了一个小时了,似乎想不出来

这太疯狂了。早在我开始玩弄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);

    }


}

确保MySQL驱动程序jar文件位于类路径中。

确保MySQL驱动程序jar文件位于类路径中。

如果尚未将驱动程序加载到应用程序中,请尝试添加Class.forName(“com.MySQL.jdbc.driver”)

如果尚未将驱动程序加载到应用程序中,请尝试添加Class.forName(“com.mysql.jdbc.Driver”)

您需要加载驱动程序。sun网页上的connector-j驱动程序附带的文档中有几个示例。以下是该文档的一个片段

 try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
  } catch (Exception ex) {
     // handle the error
  }

如果您想了解有关加载java jdbc驱动程序的更多信息,请参阅随驱动程序下载附带的connector-j.pdf的第6章。

您需要加载驱动程序。sun网页上的connector-j驱动程序附带的文档中有几个示例。以下是该文档的一个片段

 try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
  } catch (Exception ex) {
     // handle the error
  }

如果您想了解有关加载java jdbc驱动程序的更多信息,请参阅与驱动程序下载捆绑在一起的connector-j.pdf的第6章。

从链接下载该文件。解压缩它,您将在lib文件夹中找到一个.jar文件。将此文件复制到项目的lib/文件夹中。哦,我做到了……如果允许从链接下载文件,我会在一秒钟后发布一个屏幕截图。解压缩它,您将在lib文件夹中找到一个.jar文件。将此文件复制到项目的lib/文件夹中。哦,我做到了……如果允许的话,我会在一秒钟后发布一个屏幕截图。我相信已经提供了两个答案来解决这个问题。你在哪里装司机?我在你的代码中没有看到这一点。这必须在代码中完成,jvm才能加载“合适的”驱动程序。仅仅拥有.jar并不能解决您的问题。String url=“jdbc:mysql://localhost:3306/churchweb"; 字符串user=“root”;我相信已经提供了两个答案来解决这个问题。你在哪里装司机?我在你的代码中没有看到这一点。这必须在代码中完成,jvm才能加载“合适的”驱动程序。仅仅拥有.jar并不能解决您的问题。String url=“jdbc:mysql://localhost:3306/churchweb"; 字符串user=“root”;