Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- import sun.jdbc.odbc.JdbcOdbcDriver;
- class Coin
- {
- public static void main(String[] args) throws Exception
- {
- new JdbcOdbcDriver();
- String url = "jdbc:odbc:Coin";
- String user = "";
- String password = "";
- Connection con = DriverManager.getConnection(url, user, password);
- Statement stmt = con.createStatement();
- try{
- stmt.executeUpdate("CREATE TABLE Coins(CoinName VARCHAR(15),CoinValue DOUBLE(8,2))");
- }
- catch(Exception ex){
- ex.getMessage();
- }
- try{
- stmt.executeUpdate("INSERT INTO Coins VALUES('Pennies',0.88)");
- stmt.executeUpdate("INSERT INTO Coins VALUES('Nickels',1.03)");
- stmt.executeUpdate("INSERT INTO Coins VALUES('Dimes',2.71)");
- stmt.executeUpdate("INSERT INTO Coins VALUES('Quaters',6.21)");
- stmt.executeUpdate("INSERT INTO Coins VALUES('Loonies',8.43)");
- }
- catch(Exception ex){
- ex.getMessage();
- }
- stmt.close();
- con.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement