I am connecting to my database FINALLY however now I am getting the following error:
my output:
Database Established… Error Catch:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM 'users' WHERE user_id='7'' at line 1
DataBase.jpgimport java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; public class DBDemo { public static void main(String [] args){ try{ Connection conn=null;//8889 String url ="jdbc:mysql://localhost:3306/ch18"; String user="root"; String pass="root"; conn = DriverManager.getConnection(url,user,pass); System.out.println("Database Established…"); PreparedStatement ps = null; ps=conn.prepareStatement("SELECT FROM 'users' WHERE user_id='7'"); ps.execute(); System.out.println(ps); conn.close(); }catch(SQLException e){ System.out.println("Error Catch:"+e); } } }
Here is a picture of my MAMP mySQL database. This is my first time doing this and could use all the advice I can get.