mysql java没有合适的驱动程序

编程入门 行业动态 更新时间:2024-10-27 16:30:22
本文介绍了mysql java没有合适的驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在以下代码中......我没有得到合适的驱动程序..错误:请帮忙。我已经和它一起工作了一个小时,似乎无法弄明白。

In the following code..I am getting no suitable driver..error: please help. I have been working with it for an hour already and cant seem to figure it out.

这太疯狂了。在我开始搞乱GWT之前,我能够更早地做到这一点。

It is crazy. I was able to do this exact feet earlier, before I started messing with 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 Connector / J 驱动程序jar文件位于类路径中。

Make sure the MySQL Connector/J driver jar file is in your classpath.

更多推荐

mysql java没有合适的驱动程序

本文发布于:2023-10-18 23:40:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1505759.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:驱动程序   合适   mysql   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!