Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- Class.forName("org.postgresql.Driver");
- c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/javadb","postgres", "mypass");
- stmt = c.createStatement();
- String sql = "CREATE TABLE GAMES " +
- "(GAME_NAME TEXT PRIMARY KEY NOT NULL, " +
- " PRICE FLOAT NOT NULL, " +
- " URL CHAR(800))";
- String sql2 = "INSERT INTO GAMES (GAME_NAME, PRICE, URL) "
- + "VALUES (" + this.GAME_NAME + ", " +
- Float.toString(this.PRICE) + ", " +
- this.URL + ");";
- stmt.executeUpdate(sql);
- stmt.executeUpdate(sql2);
- stmt.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- public class UploadToDB {
- String GAME_NAME, URL;
- float PRICE;
- public UploadToDB(String GAME_NAME, float PRICE, String URL) {
- this.GAME_NAME = GAME_NAME;
- this.PRICE = PRICE;
- this.URL = URL;
- }
- }
Add Comment
Please, Sign In to add comment