Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- public class sqlconnect {
- public static void main(String args[]) {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
- Statement stmt = con.createStatement();
- ResultSet rs=stmt.executeQuery("select * from user_data ORDER BY RANDOM() OFFSET 0 ROWS FETCH NEXT 1 ROW ONLY");
- while(rs.next())
- System.out.println(rs.getString(1));
- con.close();
- }
- catch (Exception e){ System.out.println(e);}
- }
- }
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement