JAVA登陆界面,登陆按纽没有反映,不知道哪里有问题?请高手帮帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/01 21:30:03
以下代码是数据库和事件部分: public void actionPerformed(ActionEvent e)
{
String name=JTUserName.getText().trim();
String password=new String(JPsw.getPassword()).trim();
String box=(String)JC.getSelectedItem();
if(e.getSource()==JB1)
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //加载驱动程序
Connection conn=DriverManager.getConnection("jdbc:odbc:student","",""); //创建连接
Statement strSQL = conn.createStatement();
String sql="select * from user_Info where ID='"+name+"'";
ResultSet rs=strSQL.executeQuery(sql.toString());
while(rs.next())//如果存在,就验证密码
if(rs.getString("PWD").equals(password))//如果密码正确就提示,反之

看这错误信息,说的是不能解决的编译问题,不能够引用trim()方法到char数组类型上。大概是你的哪个变量是字符数组,而你却对这个字符数组错误的使用了字符串的的trim()方法,建议你对着错误提示的行数看看你的变量是否哪里有错

下面的说的是,你贴的代码用trim()没啥问题,trim方法是针对字符串的去掉两头的空格,你应该可以找到哪儿错了

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
Cannot invoke trim() on the array type char[]

at student.Info_Manage.actionPerformed(Info_Manage.java:76)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.proce