I do not fully understand it, so I will deepen my understanding from here.
public static void main(String[] args) {
		//DB connection
		Connection conn = null;
		PreparedStatement ps = null;
		try {
			Class.forName("org.postgresql.Driver");
			conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/DB name",
					"user",
					"password"
					);
			//Define a SQL statement
	        String sql = "INSERT INTO table name(●, ●, ●) values(?,?,?)";
			ps = conn.prepareStatement(sql);
			conn.close();
			System.out.println("Connected to DB.");
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("I failed.");
		}
		launch();
	}
        Recommended Posts