daily pastebin goal
78%
SHARE
TWEET

Untitled

a guest Jul 21st, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.ResultSet;
  4. import java.sql.Statement;
  5.  
  6. public class sqlconnect {
  7. public static void main(String args[]) {
  8. try {
  9.  
  10. Class.forName("com.mysql.jdbc.Driver");
  11. Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
  12. Statement stmt = con.createStatement();
  13. ResultSet rs=stmt.executeQuery("select * from user_data ORDER BY RANDOM() OFFSET 0 ROWS FETCH NEXT 1 ROW ONLY");
  14.  
  15. while(rs.next())
  16.  
  17. System.out.println(rs.getString(1));
  18. con.close();
  19. }
  20. catch (Exception e){ System.out.println(e);}
  21. }
  22. }
  23.    
  24. com.mysql.jdbc.exceptions.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 'OFFSET 0 ROWS FETCH NEXT 1 ROW ONLY' at line 1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top