I connected to a MySQL database that contains four fields (the first of which is an identifier, the last of which contains varchar strings).
I am trying to get the last row of the database and get the contents of the fields so that I can set them into variables (int and three rows) and use them later.
I still have a minimum minimum to establish a connection, where do I go from here? As you can see, I tried to write an SQL statement to get the last row, but that wasnβt the case, and I donβt know how to split it into separate fields.
Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/t", "", ""); Statement st = con.createStatement(); String sql = ("SELECT * FROM posts ORDER BY id DESC LIMIT 1;"); st.getResultSet().getRow(); con.close();
mino
source share