I have the datasoure and drivers set up, but for some reason this code is not updating the database.
I'm sure that the problem has to be with what's in bold, but it looks right...Code:import java.sql.*; public class TestCreateCoffeeTable { public TestCreateCoffeeTable() { } public static void main(String[] args) { try { String createStatement; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String dataSource = "jdbc:odbc:Coffeebreak"; Connection con = DriverManager.getConnection(dataSource); Statement statement1 = con.createStatement(); String insert; //add the info insert = "INSERT INTO Coffeebreak VALUES( 'Bob', 24, 23)"; statement1.executeUpdate(insert); } catch(ClassNotFoundException cnfe) { System.err.println(cnfe); } catch(SQLException sqle) { System.err.println(sqle); } catch(Exception e) { System.err.println(e); } } }
I do have the code that created the table if you need that. It created three columns, Name, ID_NUM, and Pay...But none of those are being populated.




Reply With Quote