Results 1 to 2 of 2
  1. #1
    haoinfo23 is offline Member
    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Unhappy java.sql.sqlexception : [Microsoft][ODBC microsoft access driver] too few parameters.

    PLSSSS HELP...
    i dont know what to do here :(
    help me anyone...
    i always get this msg...
    java.sql.sqlexception : [Microsoft][ODBC microsoft access driver] too few parameters. expected 1


    Java Code:
    
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package torch;
    
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import javax.swing.JOptionPane;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.sql.*;
    import java.io.*;
    
    public class addsched extends javax.swing.JFrame {
            
    
    
        /**
         * Creates new form addsched
         */
        public addsched() {
            initComponents();
            
            
        }
    
    
    
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            
                    NewJFrame c=new NewJFrame();
                    this.setVisible(false);
                    c.setVisible(true);
        }                                        
    
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    
            String eventnum = jTextField5.getText();
            String eventname1 = jTextField4.getText();
            String eventdate1 = jTextField1.getText();
            String eventplace1 = jTextField2.getText();
            String eventtime1 = jTextField3.getText();
            
            
     
        //Check if user has entered required data
    if(eventname1.equals("")||eventdate1.equals("")||eventplace1.equals("")||eventtime1.equals("")||eventnum.equals("")){
        JOptionPane.showMessageDialog(this, "Please enter required details");
    } 
    else
                {
                    {
                        try
                        {
                            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                            Connection connection=DriverManager.getConnection("jdbc:odbc:torchsched");
                            String sql="INSERT INTO torchsced (eventname,eventdate,eventplace,eventtime,eventid) VALUES("+eventname1+",'"+eventdate1+"','"+eventplace1+"','"+eventtime1+"','"+eventnum+"')";
                            Statement statement=connection.createStatement();
                            statement.execute(sql);
                            connection.close();
                            JOptionPane.showMessageDialog(null,"Event Added!","Success",JOptionPane.INFORMATION_MESSAGE);
    						//This will ask you if you want to add another cake
    						int s=JOptionPane.showConfirmDialog(null,"Add Another Record?","Add",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
    						//If the user chose yes
    						if(s==JOptionPane.YES_OPTION)
    						{
    							
    						}
    						//If the user chose no
    						if(s==JOptionPane.NO_OPTION)
    						{
    							dispose();
    						}
                        }
                        catch(Exception error)
                        {
                            JOptionPane.showMessageDialog (null, error,"Database Connection Error!", JOptionPane.ERROR_MESSAGE);
                        }
                    }
                }
        }                                        
    
       
        }
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JTextField jTextField1;
        private javax.swing.JTextField jTextField2;
        private javax.swing.JTextField jTextField3;
        private javax.swing.JTextField jTextField4;
        private javax.swing.JTextField jTextField5;
        // End of variables declaration
    }
    Last edited by Tolls; 08-13-2013 at 06:22 PM. Reason: Sorted code tags

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: java.sql.sqlexception : [Microsoft][ODBC microsoft access driver] too few paramet

    There's no '*' in the code tags, I've fixed them.
    Since you missed it, I had already split your post out into its own thread. I'll close that one.

    As for your problem, you should be using the printStackTrace() method on an exception so that you know exactly which line in your code is causing the problem.
    So my first recommendation is to do that inside your catch block and then post the full exception message and stack trace here, highlighting the line in your code from which it is thrown.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 3
    Last Post: 08-13-2013, 06:19 PM
  2. Replies: 2
    Last Post: 04-18-2012, 03:51 PM
  3. Replies: 5
    Last Post: 09-11-2011, 05:13 AM
  4. Replies: 3
    Last Post: 08-15-2011, 10:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •