The Artima Developer Community
Sponsored Link

Java Answers Forum
help with inserting into a database

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
ben

Posts: 57
Nickname: loftty
Registered: Oct, 2002

help with inserting into a database Posted: Nov 19, 2002 2:01 AM
Reply to this message Reply
Advertisement
hello i hope someone can help me
i have this code (which is below) every time i try to compile it it brings up a exception which is (could noty find output table Cust) why is this?
if someonecould help with it please i would be gratefull
also how do i know if i have selected the right database to insert into?
thanks ben




import java.sql.*;

class JD {

public static void main (String[] args) {
String data = "jdbc:odbc:World Energy";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(data,"","");
Statement st = conn.createStatement();
st.executeUpdate("INSERT INTO Cust ([first name], [last name])" +
"VALUES ('dave', 'peters')");


conn.close();
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}

}

}

Topic: Converting integers and binary numbers Previous Topic   Next Topic Topic: How do i loop

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use