Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Object[][] getTable4(String vi, String br, String mo, String ye, String mi, String pr, String co ) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
- {
- System.out.println("vin" + vi);
- System.out.println("brand" + br);
- System.out.println("model" + mo);
- System.out.println("year" + ye);
- System.out.println("mileage" + mi);
- System.out.println("price" + pr);
- System.out.println("color" + co);
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- String s1 = "jdbc:mysql://localhost:3306/carmax";
- Connection connection = DriverManager.getConnection(s1, "root", "Laughable65!");
- Statement statement = connection.createStatement();
- if (vi.equals("") && br.equals("") && mo.equals("") && ye.equals("") && mi.equals("") && pr.equals("") && co.equals(""))
- {
- vi = "%";
- br = "%";
- mo = "%";
- co = "%";
- ye = "%";
- pr = "%";
- mi = "%";
- }
- /*else
- {
- JOptionPane.showMessageDialog(null, "Please fill in all fields.", "Warning", JOptionPane.WARNING_MESSAGE);
- }*/
- statement.executeUpdate("insert into cars(vin,brand,model,year,mileage,price,color) values('" + vi + "', '" + br + "', '" + mo + "', '" + ye + "', '" + mi + "', '" + pr + "', '" + co +"')");
- ResultSet rs = statement.executeQuery("select * from cars");
- Object[][] data = new Object[100][7];
- int count=0;
- while(rs.next())
- {
- data[count][0] = rs.getString("vin");
- data[count][1] = rs.getString("brand");
- data[count][2] = rs.getString("model");
- data[count][3] = rs.getInt("year");
- data[count][4] = rs.getInt("mileage");
- data[count][5] = rs.getInt("price");
- data[count][6] = rs.getString("color");
- count++;
- }
- connection.close();
- return data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement