Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab4;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.ArrayList;
- import java.util.HashSet;
- import java.util.Scanner;
- public class Main {
- public static ArrayList<Double> listOfPoints = new ArrayList<Double>();
- private HashSet<Integer> loadedAreas;
- static String databaseName = "baza";
- public static void main(String[] args) throws SQLException, FileNotFoundException{
- DBAdapter db = new DBAdapter(databaseName);
- File file = new File("C:\\Users\\student\\Desktop\\mc-4_lab_mc_10\\dane_politechnika.txt");
- Statement st = db.connection.createStatement();
- st.execute("CREATE TABLE IF NOT EXISTS coords (id INTEGER PRIMARY KEY AUTOINCREMENT, x REAL, y REAL, h REAL);");
- Scanner scanner = new Scanner(file);
- while(scanner.hasNextDouble()){
- listOfPoints.add(scanner.nextDouble());
- //System.out.println(l.get(l.size() - 1));
- }
- AwtControlDemo c = new AwtControlDemo();
- c.showCanvasDemo();
- for(int i = 0; i < listOfPoints.size(); i+=3)
- {
- // st.execute("INSERT INTO coords (x, y, h) VALUES (" + l.get(i) + "," + l.get(i+1) + "," + l.get(i+2) + ");");
- }
- ResultSet rset = st.executeQuery("SELECT * FROM coords;");
- int rowCount = 0;
- while(rset.next()) { // Move the cursor to the next row, return false if no more row
- double x = rset.getDouble("x");
- double y = rset.getDouble("y");
- double h = rset.getDouble("h");
- System.out.println(x + ", " + y + ", " + h);
- ++rowCount;
- }
- st.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement