Reputation: 43
Updated: so as per the suggestions i changed all the column name to strings and added prepared statements-
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/minor","root","alphabet")) {
Statement st = conn.createStatement();
PreparedStatement stmt= conn.prepareStatement("select * FROM ? where name=? ;");
PreparedStatement stmt2= conn.prepareStatement("select * FROM ? where name=? ;");
stmt.setString(1, day_1);
stmt.setString(2, faculty1);
stmt2.setString(1,day_1);
stmt2.setString(2, faculty2);
ResultSet rs=stmt.executeQuery();
ResultSet rs1= stmt.executeQuery();
The day and faculty is retrieved from input screen, the queries work just fine in mysql workbench but the 'select' keyword goes missing when i try to run it from Java, see the following error- The faculty1, faculty2 is retrieved from the following- The database looks like this-
Upvotes: 0
Views: 586
Reputation: 156
select from time_interval from day_selected
is not correct, I don't think that it will execute anywhere, you need to have something between select and from, and not two from in one statement.Upvotes: 1