Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-507

hi want to insert data to an table with prepared statement, but its talking about syntax error

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • None
    • N/A
    • question
    • None
    • MariaDB 10.0.30

    Description

      private void insertDataInSql(){
              try {
                  Class.forName(dbDriver).newInstance();
                  Connection connection = DriverManager.getConnection(connectString,user,pw);
       
                  String query = "insert into task (description) values (?)";
       
                  PreparedStatement preparedStatement = connection.prepareStatement(query);
      //            preparedStatement.setString(1,this.textFieldName.getText());
                  preparedStatement.setString(1,this.textAreaDescription.getText());
                  preparedStatement.executeUpdate(query);
                  connection.close();
                  System.out.println("Inserted!");
              } catch (IllegalAccessException e) {
                  e.printStackTrace();
              } catch (InstantiationException e) {
                  e.printStackTrace();
              } catch (SQLException e) {
                  e.printStackTrace();
              } catch (ClassNotFoundException e) {
                  e.printStackTrace();
              }
      
      

      The Error: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?)' "

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            cyborg cyborg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.