~maria-captains/mariadb-java-client/trunk

« back to all changes in this revision

Viewing changes to src/main/java/org/mariadb/jdbc/MySQLResultSet.java

  • Committer: Massimo Siani
  • Date: 2014-11-06 10:35:18 UTC
  • mfrom: (534.1.1 CONJ-119)
  • Revision ID: massimo.siani@skysql.com-20141106103518-o57ig54jyw0yqe3j
Fix for CONJ-119: JDBC & MySQL incompatibilities for the ResultSet class

Show diffs side-by-side

added added

removed removed

Lines of Context:
560
560
     * @since 1.2
561
561
     */
562
562
    public boolean isBeforeFirst() throws SQLException {
 
563
        if (isClosed()) {
 
564
                throw new SQLException("The isBeforeFirst() method cannot be used on a closed ResultSet");
 
565
        }
563
566
        return (queryResult.getResultSetType() == ResultSetType.SELECT  
564
567
                && ((SelectQueryResult) queryResult).isBeforeFirst());
565
568
    }
578
581
     * @since 1.2
579
582
     */
580
583
    public boolean isAfterLast() throws SQLException {
 
584
        if (isClosed()) {
 
585
                throw new SQLException("The isAfterLast() method cannot be used on a closed ResultSet");
 
586
        }
581
587
        return queryResult.getResultSetType() == ResultSetType.SELECT
582
588
                && ((SelectQueryResult) queryResult).isAfterLast();
583
589
    }
595
601
     * @since 1.2
596
602
     */
597
603
    public boolean isFirst() throws SQLException {
 
604
        if (isClosed()) {
 
605
                throw new SQLException("The isFirst() method cannot be used on a closed ResultSet");
 
606
        }
 
607
        if (queryResult.getRows() == 0) {
 
608
                return false;
 
609
        }
598
610
        return queryResult.getResultSetType() != ResultSetType.MODIFY
599
611
                && ((SelectQueryResult) queryResult).getRowPointer() == 0;
600
612
    }
614
626
     * @since 1.2
615
627
     */
616
628
    public boolean isLast() throws SQLException {
 
629
        if (isClosed()) {
 
630
                throw new SQLException("The isLast() method cannot be used on a closed ResultSet");
 
631
        }
 
632
        if (queryResult.getRows() == 0) {
 
633
                return false;
 
634
        }
617
635
        if (queryResult.getResultSetType() == ResultSetType.SELECT)
618
636
        {
619
637
            if (queryResult instanceof CachedSelectResult) {
668
686
     * @since 1.2
669
687
     */
670
688
    public boolean first() throws SQLException {
 
689
        if (isClosed()) {
 
690
                throw new SQLException("Invalid operation on a closed result set");
 
691
        }
671
692
        if (queryResult.getResultSetType() == ResultSetType.SELECT) {
672
693
            if (!(queryResult instanceof CachedSelectResult)) {
673
694
              throw new SQLException("Invalid operation for result set type TYPE_FORWARD_ONLY");
693
714
     * @since 1.2
694
715
     */
695
716
    public boolean last() throws SQLException {
 
717
        if (isClosed()) {
 
718
                throw new SQLException("Invalid operation on a closed result set");
 
719
        }
696
720
        if (queryResult.getResultSetType() == ResultSetType.SELECT && queryResult.getRows() > 0) {
697
721
            ((SelectQueryResult) queryResult).moveRowPointerTo(queryResult.getRows() - 1);
698
722
            return true;