Advertisement
Guest User

Untitled

a guest
Jun 17th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import java.sql.*;
  2. import sun.jdbc.odbc.JdbcOdbcDriver;
  3.  
  4. class Coin
  5. {
  6. public static void main(String[] args) throws Exception
  7. {
  8. new JdbcOdbcDriver();
  9.  
  10. String url = "jdbc:odbc:Coin";
  11. String user = "";
  12. String password = "";
  13. Connection con = DriverManager.getConnection(url, user, password);
  14. Statement stmt = con.createStatement();
  15.  
  16. try{
  17. stmt.executeUpdate("CREATE TABLE Coins(CoinName VARCHAR(15),CoinValue DOUBLE(8,2))");
  18. }
  19. catch(Exception ex){
  20. ex.getMessage();
  21. }
  22.  
  23. try{
  24. stmt.executeUpdate("INSERT INTO Coins VALUES('Pennies',0.88)");
  25. stmt.executeUpdate("INSERT INTO Coins VALUES('Nickels',1.03)");
  26. stmt.executeUpdate("INSERT INTO Coins VALUES('Dimes',2.71)");
  27. stmt.executeUpdate("INSERT INTO Coins VALUES('Quaters',6.21)");
  28. stmt.executeUpdate("INSERT INTO Coins VALUES('Loonies',8.43)");
  29. }
  30. catch(Exception ex){
  31. ex.getMessage();
  32. }
  33.  
  34. stmt.close();
  35. con.close();
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement