1 30 31 32 package org.hsqldb.jdbc; 33 34 import java.sql.SQLException ; 35 36 import org.hsqldb.HsqlException; 37 import org.hsqldb.Result; 38 import org.hsqldb.Trace; 39 40 48 public class Util { 49 50 static final void throwError(HsqlException e) throws SQLException { 51 throw new SQLException (e.getMessage(), e.getSQLState(), 52 e.getErrorCode()); 53 } 54 55 static final void throwError(Result r) throws SQLException { 56 throw new SQLException (r.getMainString(), r.getSubString(), 57 r.getStatementID()); 58 } 59 60 public static final SQLException sqlException(HsqlException e) { 61 return new SQLException (e.getMessage(), e.getSQLState(), 62 e.getErrorCode()); 63 } 64 65 static final SQLException sqlException(int id) { 66 return sqlException(Trace.error(id)); 67 } 68 69 static final SQLException sqlException(int id, String message) { 70 return sqlException(Trace.error(id, message)); 71 } 72 73 static final SQLException sqlException(int id, int subId, Object [] add) { 74 return sqlException(Trace.error(id, subId, add)); 75 } 76 77 static final SQLException notSupported() { 78 return sqlException(Trace.error(Trace.FUNCTION_NOT_SUPPORTED)); 79 } 80 81 public static SQLException nullArgument() { 82 return sqlException(Trace.INVALID_JDBC_ARGUMENT); 83 } 84 85 static SQLException nullArgument(String name) { 86 return sqlException(Trace.INVALID_JDBC_ARGUMENT, name + ": null"); 87 } 88 89 public static SQLException invalidArgument() { 90 return sqlException(Trace.INVALID_JDBC_ARGUMENT); 91 } 92 93 public static SQLException invalidArgument(String name) { 94 return sqlException(Trace.INVALID_JDBC_ARGUMENT, name); 95 } 96 97 public static SQLException outOfRangeArgument() { 98 return sqlException(Trace.INVALID_JDBC_ARGUMENT); 99 } 100 101 public static SQLException outOfRangeArgument(String name) { 102 return sqlException(Trace.INVALID_JDBC_ARGUMENT, name); 103 } 104 105 public static SQLException connectionClosedException() { 106 return sqlException(Trace.CONNECTION_IS_CLOSED); 107 } 108 109 } 110 | Popular Tags |