Results 1 to 20 of 24
Thread: SQL problems
- 10-29-2011, 07:08 PM #1
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
SQL problems
Hi. I have a java class that the user puts in the information and then it sends it to another class to put it into the database. But its not working. It's running but not putting any information in the database. Here's the code from the program that sends the information:
and here's the code from the SQL class that is suppose to insert the information into the database.Java Code:private void button1MouseClicked(MouseEvent e) { String name1 = textField1.getText(); String name2 = textField2.getText(); String playup = textField3.getText(); String rotate = textField4.getText(); SQLUserinfo suser = new SQLUserinfo(name1, name2, playup, rotate); Scorekeeper scrkper = new Scorekeeper(""); this.setVisible(false); }
please help me!Java Code:private String naam1; private String naam2; private String playup; private String rotate; public SQLUserinfo(String nm1, String nm2, String plyp, String rtte) { naam1 = nm1; naam2 = nm2; playup = plyp; rotate = rtte; } SQLUserinfo ()throws SQLException { updateMthd("INSERT INTO Extra" + "VALUES(naam1, naam2, playup, rotate)"); }
-
Re: SQL problems
Your SQLUserinfo class has two constructors, one that appears to try to update the database (method not shown, and it appears to try to do this before any data has been placed into the class fields), and the other that doesn't. Guess which one you're calling?
- 10-29-2011, 07:48 PM #3
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
haha lol cool stated
here is the updateMthd that I left out erlier:
I did the following with the constructor issue:Java Code:void updateMthd (String update) throws SQLException { stmt = conn.createStatement(); stmt.executeUpdate(update); stmt.close(); }
and took out this because it was giving an error.Java Code:public class SQLUserinfo { Connection conn = connect(); Statement stmt; private String naam1; private String naam2; private String playup; private String rotate; SQLUserinfo (String nm1, String nm2, String plyp, String rtte)throws SQLException { naam1 = nm1; naam2 = nm2; playup = plyp; rotate = rtte; updateMthd("INSERT INTO Extra" + "VALUES(naam1, naam2, playup, rotate)"); }
But now it gives me the following error at the Userinfo class:Java Code:public static void main (String [] args) throws SQLException { //new SQLUserinfo (); }
Userinfo.java:31: unreported exception java.sql.SQLException; must be caught or declared to be thrown
SQLUserinfo suser = new SQLUserinfo(name1, name2, playup, rotate);
^
At this code:
Java Code:private void button1MouseClicked(MouseEvent e) { String name1 = textField1.getText(); String name2 = textField2.getText(); String playup = textField3.getText(); String rotate = textField4.getText(); SQLUserinfo suser = new SQLUserinfo(name1, name2, playup, rotate); Scorekeeper scrkper = new Scorekeeper(""); this.setVisible(false); }
- 10-29-2011, 07:49 PM #4
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
Oh that arrow is suppose to be at new
-
Re: SQL problems
Your constructor throws an exception and this must be caught and handled. If this makes no sense, please check out the exceptions tutorial at the Oracle Java tutorials.
- 10-29-2011, 08:18 PM #6
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
It makes sense..I know a little of error handling and exceptions, but not enough to solve my problem. I have red through some of the tutorials...
- 10-29-2011, 08:38 PM #7
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
please help!!
-
Re: SQL problems
- 10-29-2011, 08:57 PM #9
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
I RunTimeException
but now it gives me the following error to do with the other class.Java Code:private void button1MouseClicked(MouseEvent e) { try { String name1 = textField1.getText(); String name2 = textField2.getText(); String playup = textField3.getText(); String rotate = textField4.getText(); SQLUserinfo suser = new SQLUserinfo(name1, name2, playup, rotate); Scorekeeper scrkper = new Scorekeeper(""); this.setVisible(false); } catch (SQLException ex) { throw new RuntimeException(ex); } }
Java Code:Connected to database Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. at Userinfo.button1MouseClicked(Userinfo.java:40) at Userinfo.access$100(Userinfo.java:12) at Userinfo$2.mouseClicked(Userinfo.java:204) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253) at java.awt.Component.processMouseEvent(Component.java:6041) at javax.swing.JComponent.processMouseEvent(JComponent.java:3265) at java.awt.Component.processEvent(Component.java:5803) at java.awt.Container.processEvent(Container.java:2058) at java.awt.Component.dispatchEventImpl(Component.java:4410) at java.awt.Container.dispatchEventImpl(Container.java:2116) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) at java.awt.Container.dispatchEventImpl(Container.java:2102) at java.awt.Window.dispatchEventImpl(Window.java:2429) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) Caused by: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110) at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338) at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288) at SQLUserinfo.updateMthd(SQLUserinfo.java:75) at SQLUserinfo.<init>(SQLUserinfo.java:24) at Userinfo.button1MouseClicked(Userinfo.java:34) ... 23 more
- 10-29-2011, 09:05 PM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Re: SQL problems
In your method that receives the String that makes up your SQL query, print it and see for yourself; the query isn't correct.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-30-2011, 11:50 AM #11
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
I can't figure out what's wrong. I suspect it might have something to do with the Userinfo class where i put in the RuntimeException. Otherwise it's got something to do with my database. I just really don't know.
- 10-30-2011, 11:58 AM #12
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Re: SQL problems
According to your code:
Your database receives the String "INSERT INTO ExtraVALUES(naam1, naam2, playup, rotate)" Note the lack of a space between "Extra" and "VALUES" ...Java Code:updateMthd("INSERT INTO Extra" + "VALUES(naam1, naam2, playup, rotate)");
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-30-2011, 12:03 PM #13
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
I have changed that a long time ago and it still doens't work.
Java Code:private String naam1; private String naam2; private String playup; private String rotate; SQLUserinfo (String nm1, String nm2, String plyp, String rtte)throws SQLException { naam1 = nm1; naam2 = nm2; playup = plyp; rotate = rtte; updateMthd("INSERT INTO Extra VALUES(naam1, naam2, playup, rotate)"); }
- 10-30-2011, 12:32 PM #14
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Re: SQL problems
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-30-2011, 12:46 PM #15
Member
- Join Date
- Oct 2011
- Posts
- 92
- Rep Power
- 0
Re: SQL problems
As josah said, ""INSERT INTO Extra VALUES(naam1, naam2, playup, rotate)" means nothing too the sql engine you're using.
Try and think about what naam1, naam2, playup and rotate are, and how you're trying to use them. Then, if you get really stuck, come reply on here and I'm sure one of us will be happy too talk you through where you've gone wrong :)
- 10-30-2011, 01:02 PM #16
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
It wasn't on purpose. It was whilst I was trying everything, and I forgot the code here wasn't the same as mine. I know you have to sort out a LOT of problems here and you can get fed up easily, but through all the rush of me trying to finish my project in time and trying stuff to try and solve the problem, something like this happens easily... (and it wouldn't be logic to post everything I have tried)
I don't know what to try anymore.
Really sorry though
Johannes
- 10-30-2011, 01:05 PM #17
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
Here is both my programs:
Java Code://Johannes van Zyl //Userinfo //GUI wat die inligting vanaf die gebruiker kry. import java.sql.*; import java.awt.*; import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.event.*; public class Userinfo extends JDialog { public Userinfo() { initComponents(); this.setVisible(true); } public static void main(String[]args) { Userinfo obj = new Userinfo(); } private void button1MouseClicked(MouseEvent e) { String name1 = textField1.getText(); String name2 = textField2.getText(); String playup = textField3.getText(); String rotate = textField4.getText(); try { SQLUserinfo suser = new SQLUserinfo(name1, name2, playup, rotate); } catch (SQLException ex) { throw new RuntimeException(ex); } finally { Scorekeeper scrkper = new Scorekeeper(""); this.setVisible(false); } } private void button2MouseClicked(MouseEvent e) { Scorekeeper scrkper = new Scorekeeper(""); this.setVisible(false); } private void radioButton1MouseClicked(MouseEvent e) { // TODO add your code here } private void radioButton2MouseClicked(MouseEvent e) { // TODO add your code here } private void menuItem1ActionPerformed(ActionEvent e) { int antwoord = JOptionPane.showConfirmDialog(null, "Are you sure you want to exit?"); if (antwoord == JOptionPane.YES_OPTION) { System.exit(0); } } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license menuBar1 = new JMenuBar(); menu1 = new JMenu(); menuItem1 = new JMenuItem(); label1 = new JLabel(); label2 = new JLabel(); textField1 = new JTextField(); textField2 = new JTextField(); label3 = new JLabel(); label4 = new JLabel(); textField3 = new JTextField(); textField4 = new JTextField(); button1 = new JButton(); label5 = new JLabel(); textField5 = new JTextField(); textField6 = new JTextField(); textField7 = new JTextField(); separator1 = new JSeparator(); label6 = new JLabel(); label7 = new JLabel(); label8 = new JLabel(); label9 = new JLabel(); label10 = new JLabel(); label12 = new JLabel(); label13 = new JLabel(); textField8 = new JTextField(); textField9 = new JTextField(); textField10 = new JTextField(); textField12 = new JTextField(); textField13 = new JTextField(); textField14 = new JTextField(); scrollPane1 = new JScrollPane(); textPane1 = new JTextPane(); button2 = new JButton(); label11 = new JLabel(); radioButton1 = new JRadioButton(); radioButton2 = new JRadioButton(); separator2 = new JSeparator(); //======== this ======== setTitle("Table Tennis Score Keeper"); Container contentPane = getContentPane(); contentPane.setLayout(null); //======== menuBar1 ======== { //======== menu1 ======== { menu1.setText("Options"); //---- menuItem1 ---- menuItem1.setText("Exit"); menuItem1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItem1ActionPerformed(e); } }); menu1.add(menuItem1); } menuBar1.add(menu1); } setJMenuBar(menuBar1); //---- label1 ---- label1.setText("Player 1 name"); label1.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label1); label1.setBounds(75, 90, 86, 15); //---- label2 ---- label2.setText("Player 2 name"); label2.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label2); label2.setBounds(75, 140, 95, 15); //---- textField1 ---- textField1.setBackground(Color.red); textField1.setForeground(Color.white); textField1.setFont(new Font("Tahoma", Font.BOLD, 16)); textField1.setText("Ping"); textField1.setToolTipText("player 1 name"); contentPane.add(textField1); textField1.setBounds(40, 110, 155, 26); //---- textField2 ---- textField2.setBackground(Color.blue); textField2.setForeground(Color.white); textField2.setFont(new Font("Tahoma", Font.BOLD, 16)); textField2.setText("Pong"); textField2.setToolTipText("Player 2 name"); contentPane.add(textField2); textField2.setBounds(40, 160, 155, 26); //---- label3 ---- label3.setText("Play up to"); label3.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label3); label3.setBounds(245, 90, 70, 15); //---- label4 ---- label4.setText("Rotates serves every"); label4.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label4); label4.setBounds(210, 140, 140, 15); //---- textField3 ---- textField3.setFont(new Font("Tahoma", Font.PLAIN, 16)); textField3.setText("21"); textField3.setHorizontalAlignment(SwingConstants.CENTER); textField3.setToolTipText("Match total"); contentPane.add(textField3); textField3.setBounds(255, 110, 45, 26); //---- textField4 ---- textField4.setFont(new Font("Tahoma", Font.PLAIN, 16)); textField4.setText("2"); textField4.setHorizontalAlignment(SwingConstants.CENTER); textField4.setToolTipText("serve rotations"); contentPane.add(textField4); textField4.setBounds(255, 160, 45, 26); //---- button1 ---- button1.setText("Start"); button1.setFont(new Font("Tahoma", Font.BOLD, 16)); button1.setToolTipText("Starts program"); button1.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { button1MouseClicked(e); } }); contentPane.add(button1); button1.setBounds(160, 200, 80, 29); //---- label5 ---- label5.setText("Date:"); label5.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label5); label5.setBounds(40, 65, 45, 15); //---- textField5 ---- textField5.setFont(new Font("Tahoma", Font.PLAIN, 16)); textField5.setText("YYYY"); textField5.setHorizontalAlignment(SwingConstants.LEFT); textField5.setToolTipText("Year"); contentPane.add(textField5); textField5.setBounds(75, 60, 50, 26); //---- textField6 ---- textField6.setFont(new Font("Tahoma", Font.PLAIN, 16)); textField6.setText("MM"); textField6.setHorizontalAlignment(SwingConstants.LEFT); textField6.setToolTipText("Month"); contentPane.add(textField6); textField6.setBounds(125, 60, 30, 26); //---- textField7 ---- textField7.setFont(new Font("Tahoma", Font.PLAIN, 16)); textField7.setText("DD"); textField7.setHorizontalAlignment(SwingConstants.LEFT); textField7.setToolTipText("Day"); contentPane.add(textField7); textField7.setBounds(155, 60, 30, 26); contentPane.add(separator1); separator1.setBounds(0, 235, 415, 5); //---- label6 ---- label6.setText("Extra player information (not compulsory):"); label6.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label6); label6.setBounds(55, 240, 275, 15); //---- label7 ---- label7.setText("Date of birth:"); label7.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label7); label7.setBounds(15, 260, 90, 15); //---- label8 ---- label8.setText("Gender:"); label8.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label8); label8.setBounds(15, 280, 55, 15); //---- label9 ---- label9.setText("Place of birth:"); label9.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label9); label9.setBounds(15, 305, 95, 15); //---- label10 ---- label10.setText("Member of:"); label10.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label10); label10.setBounds(15, 325, 75, 15); //---- label12 ---- label12.setText("Current rank:"); label12.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label12); label12.setBounds(15, 345, 85, 15); //---- label13 ---- label13.setText("Motto:"); label13.setFont(new Font("Tahoma", Font.BOLD, 12)); contentPane.add(label13); label13.setBounds(15, 360, 45, 15); //---- textField8 ---- textField8.setText("YYYY"); textField8.setHorizontalAlignment(SwingConstants.CENTER); textField8.setToolTipText("Year"); contentPane.add(textField8); textField8.setBounds(115, 260, 35, 20); //---- textField9 ---- textField9.setText("MM"); textField9.setHorizontalAlignment(SwingConstants.CENTER); textField9.setToolTipText("Month"); contentPane.add(textField9); textField9.setBounds(150, 260, 25, 20); //---- textField10 ---- textField10.setText("DD"); textField10.setHorizontalAlignment(SwingConstants.CENTER); textField10.setToolTipText("Day"); contentPane.add(textField10); textField10.setBounds(175, 260, 25, 20); contentPane.add(textField12); textField12.setBounds(115, 305, 240, 20); contentPane.add(textField13); textField13.setBounds(115, 325, 240, 20); contentPane.add(textField14); textField14.setBounds(115, 345, 240, 20); //======== scrollPane1 ======== { scrollPane1.setViewportView(textPane1); } contentPane.add(scrollPane1); scrollPane1.setBounds(115, 365, 240, 55); //---- button2 ---- button2.setText("Save information and start"); button2.setFont(new Font("Tahoma", Font.BOLD, 16)); button2.setToolTipText("Saves information and starts program"); button2.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { button2MouseClicked(e); } }); contentPane.add(button2); button2.setBounds(70, 430, 270, 29); //---- label11 ---- label11.setText("Table Tennis Score Keeper"); label11.setFont(new Font("Tahoma", Font.BOLD, 30)); label11.setForeground(new Color(0, 102, 0)); contentPane.add(label11); label11.setBounds(5, 0, 405, 37); //---- radioButton1 ---- radioButton1.setText("Male"); radioButton1.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { radioButton1MouseClicked(e); } }); contentPane.add(radioButton1); radioButton1.setBounds(115, 280, 70, 23); //---- radioButton2 ---- radioButton2.setText("Female"); radioButton2.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { radioButton2MouseClicked(e); } }); contentPane.add(radioButton2); radioButton2.setBounds(185, 280, 85, 23); contentPane.add(separator2); separator2.setBounds(0, 475, 415, 5); { // compute preferred size Dimension preferredSize = new Dimension(); for(int i = 0; i < contentPane.getComponentCount(); i++) { Rectangle bounds = contentPane.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = contentPane.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; contentPane.setMinimumSize(preferredSize); contentPane.setPreferredSize(preferredSize); } pack(); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // Generated using JFormDesigner non-commercial license private JMenuBar menuBar1; private JMenu menu1; private JMenuItem menuItem1; private JLabel label1; private JLabel label2; private JTextField textField1; private JTextField textField2; private JLabel label3; private JLabel label4; private JTextField textField3; private JTextField textField4; private JButton button1; private JLabel label5; private JTextField textField5; private JTextField textField6; private JTextField textField7; private JSeparator separator1; private JLabel label6; private JLabel label7; private JLabel label8; private JLabel label9; private JLabel label10; private JLabel label12; private JLabel label13; private JTextField textField8; private JTextField textField9; private JTextField textField10; private JTextField textField12; private JTextField textField13; private JTextField textField14; private JScrollPane scrollPane1; private JTextPane textPane1; private JButton button2; private JLabel label11; private JRadioButton radioButton1; private JRadioButton radioButton2; private JSeparator separator2; // JFormDesigner - End of variables declaration //GEN-END:variables }Hope it's enough information...Java Code://Johannes van Zyl //java class for Userinfo and Scorekeeper and SQL for SQLUserinfo.mdb import java.sql.*; import java.io.*; import javax.swing.*; public class SQLUserinfo { Connection conn = connect(); Statement stmt; private String naam1; private String naam2; private String playup; private String rotate; SQLUserinfo (String nm1, String nm2, String plyp, String rtte)throws SQLException { updateMthd("INSERT INTO Extra VALUES('naam1', 'naam2', 'playup', 'rotate')"); displayMthd("", "SELECT * FROM Extra"); } //Make a connection public Connection connect () { //Load driver try { Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException e) { System.out.println ("Cannot load driver"); } //Add name of database try { String dbName = "SQLUserinfo.mdb"; conn = DriverManager.getConnection ("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + dbName); System.out.println ("Connected to database\n"); } catch (Exception e) { System.out.println ("Unable to connect to database"); } return conn; } //Create resultset and display information void displayMthd (String heading, String sqlStmt) throws SQLException { stmt = conn.createStatement(); //Standard method from Statement class ResultSet rs = stmt.executeQuery(sqlStmt); //Method from Resultset class (also update query) System.out.println(); while (rs.next()) { String p1 = rs.getString("Player1"); String p2 = rs.getString("Player2"); String put = rs.getString("Play up to"); String rot = rs.getString("Rotate"); } System.out.println(); stmt.close(); } //Update data in table void updateMthd (String update) throws SQLException { stmt = conn.createStatement(); stmt.executeUpdate(update); stmt.close(); } //Method to create spaces for formatting display private String spaces (String s, int width) { String temp = ""; for (int I = 0; I<= width - s.length(); I++) { temp = temp + " "; } return temp; } //Main method public static void main (String [] args) throws SQLException { //new SQLUserinfo (); } }
- 10-30-2011, 01:16 PM #18
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Re: SQL problems
What is the error now that was thrown?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-30-2011, 01:19 PM #19
Member
- Join Date
- Oct 2011
- Posts
- 92
- Rep Power
- 0
Re: SQL problems
You're missing a painfully obvious issue here bud.
You need to debug your program, and look at the actual SQL statement being sent too the engine. Hopefully that'll clear it up for you.Java Code:updateMthd("INSERT INTO Extra VALUES('naam1', 'naam2', 'playup', 'rotate')");
- 10-30-2011, 01:20 PM #20
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: SQL problems
When i run the Userinfo class and click on the start button it gives the following errors:
Java Code:Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 4. at Userinfo.button1MouseClicked(Userinfo.java:38) at Userinfo.access$100(Userinfo.java:12) at Userinfo$2.mouseClicked(Userinfo.java:207) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253) at java.awt.Component.processMouseEvent(Component.java:6041) at javax.swing.JComponent.processMouseEvent(JComponent.java:3265) at java.awt.Component.processEvent(Component.java:5803) at java.awt.Container.processEvent(Container.java:2058) at java.awt.Component.dispatchEventImpl(Component.java:4410) at java.awt.Container.dispatchEventImpl(Container.java:2116) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) at java.awt.Container.dispatchEventImpl(Container.java:2102) at java.awt.Window.dispatchEventImpl(Window.java:2429) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) Caused by: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 4. at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110) at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338) at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288) at SQLUserinfo.updateMthd(SQLUserinfo.java:80) at SQLUserinfo.<init>(SQLUserinfo.java:25) at Userinfo.button1MouseClicked(Userinfo.java:34) ... 23 more ----jGRASP: operation complete.
Similar Threads
-
need help with several problems
By tidus1103 in forum New To JavaReplies: 4Last Post: 03-11-2011, 01:10 AM -
InputStream/Jar Problems/File IO Problems
By rdjava in forum Advanced JavaReplies: 31Last Post: 01-17-2011, 11:12 AM -
Problems here
By Keno777 in forum New To JavaReplies: 2Last Post: 11-13-2009, 11:35 AM -
JAR problems
By Evil Smurf in forum New To JavaReplies: 4Last Post: 09-01-2009, 01:17 AM -
many to many problems
By cecily in forum JDBCReplies: 1Last Post: 08-02-2007, 05:51 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks