当前位置: 首页 > 知识库问答 >
问题:

插入到数据库错误java

齐晟
2023-03-14
String _passwordField1 = passwordField1.getText();
int _password = Integer.parseInt(_passwordField1);

try
        {
            String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
            Class.forName(driver);

            String url = "jdbc:odbc:Database";

            conn = DriverManager.getConnection(url);

            String command = "insert into Member (Password) values (?)";

            PreparedStatement statement = conn.prepareStatement(command);

            statement.setInt(2, _password);

            statement.executeUpdate(command);
        }

catch (Exception e) 
        {
             System.err.println(e.getMessage());

            _sound.PlaySound(2);

            _infoBox.ShowMessageBox(e.getMessage(), "Error", 2);

            _reminder = new Reminder(1);

            JOptionPane.showOptionDialog(null, "Program will be closed due to error", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new Object[]{}, null);

            System.exit(0);
        }

共有1个答案

郎正初
2023-03-14
int _password = Integer.parseInt(_passwordField1);

例外情况很明显。

不能将名为“Xavega”的字符串转换为整数

摆脱那条线。因为不需要将密码转换为integer

  updateTotal.setString(1, _passwordField1);
 类似资料:
  • 我在尝试将记录插入数据库时遇到错误。 错误如下: 守则: 数据库:

  • 请在Access数据库中插入数据时遇到错误代码。它一直说我的INSERT INTO语句中存在sytanx错误。有人能帮我解决这个问题吗?这是代码

  • 错误 用消息'SQLSTATE[HY000]照亮/数据库/查询异常:一般错误:1表配置文件没有名为标题的列(SQL:插入到配置文件(标题,描述,user_id,updated_at,created_at)值(asd,123123, 2, 2020-07-31 10:19:03, 2020-07-31 10:19:03))' 这是我在“$profile”时遇到的错误- 这是2020年07月31日07

  • 我尝试从本地磁盘(Windows 10)向我的RDS MySQL数据库插入一个blob。然而,我的查询没有插入blob。新行包含所有其他列,但blob为空。 以下是我尝试过的: 我设置了文件的读/写权限 安全文件设置为/tmp。。。我不知道这是什么意思。这是路径还是变量?如果它是一个变量,我已经尝试从用户/系统变量“TMP”的路径上传blob,但没有成功。我无法更改安全文件,因为RDS允许更改。。

  • 问题内容: 从Actor中读取的文件:Zac Efron 传记:他出生于加利福尼亚州的圣路易斯·奥比斯波,并在阿罗约·格兰德附近长大。在几集《夏姆兰》(2004)的客串中,他以女孩疯狂的卡梅隆·贝尔的身份参加常规演出。埃夫隆还出演过许多飞行员,例如卡尔·兰克(Carl Laemke)的《大世界》(2003)(电视)和三重播放(2004)(TV)。 More_Bio:Efron于2006年6月毕业于

  • 利用INSERT语句将数据插入表中 数据插入 用来插入(添加)行到数据库。 插入完整的行 插入行的一部分 插入某些查询结果 插入完整的行 指定表名和被插入到新行中的值 编写依赖与特定列次序的SQL语句,这样做有时会出错,但编写方便。 mysql> INSERT INTO Customers -> VALUES('1000000006', -> 'Toy Land', ->