• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

executeUpdate() ?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The class runs fine when I omit s.executeUpdate(). I am unsure of what the problem might be. I am using Windows XP and connecting to an Access database. Thanks for your help.
Nick
package be314;
import java.sql.*;
public class Fordate1 {
public static void main (String args []) {
try {
Class.forName(
"sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection(
"jdbc dbc:Music");
System.out.println("A success");
Statement s = c.createStatement();
s.executeUpdate (
"CREATE TABLE Customer (CustomerID INTEGER, Address VARCHAR
(25))");
ResultSet r =
s.executeQuery(
"SELECT Albums.Album FROM Albums WHERE Albums.Album)
Between 'A' And 'B')");
while(r.next()) {
System.out.println(
r.getString("Album"));
}
System.exit(0);
} catch (Exception) {
System.exit(0);
}
}
}
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would greatly help if you would print the error message in the catch block. My guess, from looking at your source code, is that the table Customer that you're trying to create already exists in the database.
 
Nick Neidig
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Lu. I went ahead and printed out the error message and you were absolutely correct.
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you have an error in the syntax of your SELECT statement after WHERE. Take off the paren.
 
All of the following truths are shameless lies. But what about this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic