/** * Initialize SqlError object * */ internal SqlError(SQLException e, AbstractDBConnection connection) : base(e, connection) { if (connection != null) { _serverVersion = connection.ServerVersion; } }
protected void clearErrors() { _exception = null; _errorMessage = null; _errorCode = 0; _warnings = null; }
public static SQLException getSQLException(string sqlState) { string reason = getReason(sqlState); SQLException e = new SQLException(reason, sqlState, -99999); return(e); }
/*Questa funzione compone la home prelevando dalla tabella del database contenente le pagine statiche la pagina con Id "Home".*/ protected void Page_Load(object sender, EventArgs e) { String idURL = Request.QueryString["Id"]; query.CommandText = "Select * from PagineH where Id='Home'"; try { connessione.Open(); riga = query.ExecuteReader(); if (riga.HasRows) { riga.Read(); pagina.InnerHtml = riga["Contenuto"].ToString(); } else //Se la pagine di ID richiesto non viene trovata viene restituito un errore 404 { pagina.InnerHtml = "Errore 404: pagina non trovata"; } connessione.Close(); } catch (Exception SQLException) { try { connessione.Close(); } finally { pagina.InnerHtml = SQLException.ToString(); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public long length() throws SQLException public long length() { if (length_ == -1) { attribs_.StartOffset = 0; attribs_.RequestedSize = 0; attribs_.ReturnCurrentLengthIndicator = 0xF1; try { length_ = -1; conn_.retrieveLOBData(attribs_, this); if (length_ == -1) { throw new IOException("LOB length not retrieved."); } } catch (IOException io) { SQLException sql = new SQLException(io.ToString()); sql.initCause(io); throw sql; } } return(length_); }
protected static PDOStatement prepare(Env env, PDO pdo, PDOError error, string query, bool isCatchException) { PDOStatement stmt = new PDOStatement(env, pdo, error); query = stmt.parseQueryString(env, query); stmt._stmt = pdo.getConnection().prepare(env, query); SQLException e = stmt._stmt.getException(); if (e != null) { if (!isCatchException) { throw e; } error.error(env, e); } // php/1s41 - oracle can't handle this //_preparedStatement.setEscapeProcessing(false); stmt.queryString = query; return(stmt); }
// pos is 1-based! //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public byte[] getBytes(long pos, int length) throws SQLException public sbyte[] getBytes(long pos, int length) { if (pos <= 0) { throw new SQLException("Bad position: " + pos); } int ipos = (int)(pos & 0x7FFFFFFF); attribs_.StartOffset = ipos - 1; attribs_.RequestedSize = length; attribs_.ReturnCurrentLengthIndicator = 0xF1; try { tempOutput_ = new MemoryStream(); conn_.retrieveLOBData(attribs_, this); tempOutput_.Flush(); tempOutput_.Close(); return(tempOutput_.toByteArray()); } catch (IOException io) { SQLException sql = new SQLException(io.ToString()); sql.initCause(io); throw sql; } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public int setString(long pos, String str, int offset, int len) throws SQLException public virtual int setString(long pos, string str, int offset, int len) { if (pos <= 0) { throw new SQLException("Bad position: " + pos); } int ipos = (int)(pos & 0x7FFFFFFF); int total = length_ - ipos + 1; if (total > len) { total = len; } try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] bytes = com.ibm.jtopenlite.Conv.stringToEBCDICByteArray(str, ccsid_); sbyte[] bytes = Conv.stringToEBCDICByteArray(str, ccsid_); Array.Copy(bytes, offset, data_, offset_ + ipos - 1, total); return(total); } catch (UnsupportedEncodingException uee) { SQLException sql = new SQLException(uee.ToString()); sql.initCause(uee); throw sql; } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public long position(String patternString, long start) throws SQLException public virtual long position(string patternString, long start) { if (start <= 0) { throw new SQLException("Bad start: " + start); } try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] pattern = com.ibm.jtopenlite.Conv.stringToEBCDICByteArray(patternString, ccsid_); sbyte[] pattern = Conv.stringToEBCDICByteArray(patternString, ccsid_); for (int i = (int)(start & 0x7FFFFFFF) + offset_ - 1; i < offset_ + length_; ++i) { bool match = true; for (int j = 0; match && j < pattern.Length; ++j) { if (data_[i] != pattern[j]) { match = false; } } if (match) { return(i - offset_); } } return(-1); } catch (UnsupportedEncodingException uee) { SQLException sql = new SQLException(uee.ToString()); sql.initCause(uee); throw sql; } }
// pos is 1-based! //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public String getSubString(long pos, int length) throws SQLException public virtual string getSubString(long pos, int length) { if (pos <= 0) { throw new SQLException("Bad position: " + pos); } int ipos = (int)(pos & 0x7FFFFFFF); int total = length_ - ipos + 1; if (total > length) { total = length; } sbyte[] data = new sbyte[total]; Array.Copy(data_, offset_ + ipos - 1, data, 0, total); try { return(Conv.ebcdicByteArrayToString(data_, offset_ + ipos - 1, total, ccsid_)); } catch (UnsupportedEncodingException uee) { SQLException sql = new SQLException(uee.ToString()); sql.initCause(uee); throw sql; } }
protected void setError(Env env, SQLException e) { log.log(Level.FINE, e.getMessage(), e); _e = e; _errorMessage = e.getMessage(); _errorCode = e.getErrorCode(); }
protected AbstractDbError(SQLException e, AbstractDBConnection connection) { _e = e; if (connection != null) { _jdbcProvider = connection.JdbcProvider; } }
protected void update(String Id) { query.CommandText = "Select * from Schede where Id='" + Id + "'"; try { connessione.Open(); riga = query.ExecuteReader(); if (riga.HasRows) { riga.Read(); Nome.Text = riga["Nome"].ToString(); if (!string.IsNullOrEmpty(riga["Descrizione"].ToString())) { Descrizione.Text = riga["Descrizione"].ToString(); Descrizione.Visible = true; } else { Descrizione.Visible = false; } if (!string.IsNullOrEmpty(riga["Immagine"].ToString())) { Foto.Src = "~\\" + riga["Immagine"].ToString(); Foto.Visible = true; } else { Foto.Visible = false; } if (!string.IsNullOrEmpty(riga["Audio"].ToString())) { audioplayer.Src = "~\\" + riga["Audio"].ToString(); audioplayer.Visible = true; } else { audioplayer.Visible = false; } } else { Nome.Text = "La scheda richiesta non esiste"; } connessione.Close(); } catch (Exception SQLException) { try { connessione.Close(); } finally { Descrizione.Text = SQLException.ToString(); } } }
protected AbstractDbErrorCollection(SQLException e, AbstractDBConnection connection) { _list = new ArrayList(); while (e != null) { _list.Add(CreateDbError(e, connection)); e = e.getNextException(); } }
protected void saveErrors(SQLException e) { _exception = e; _errorMessage = e.getMessage(); if (_errorMessage == null || "".equals(_errorMessage)) { _errorMessage = e.ToString(); } _errorCode = e.getErrorCode(); }
/// <summary> /// This is a ByteArrayInputStream wrapper around String.getBytes("ASCII"). /// /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public InputStream getAsciiStream() throws SQLException public virtual Stream getAsciiStream() { try { return(new MemoryStream(Conv.ebcdicByteArrayToString(data_, offset_, length_, ccsid_).GetBytes(Encoding.ASCII))); } catch (UnsupportedEncodingException uee) { SQLException sql = new SQLException(uee.ToString()); sql.initCause(uee); throw sql; } }
/// <summary> /// This is a StringReader wrapper. /// /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public Reader getCharacterStream() throws SQLException public virtual Reader getCharacterStream() { try { return(new StringReader(Conv.ebcdicByteArrayToString(data_, offset_, length_, ccsid_))); } catch (UnsupportedEncodingException uee) { SQLException sql = new SQLException(uee.ToString()); sql.initCause(uee); throw sql; } }
/** * Save an error for subsequent calls to * {@link #errorCode} and {@link #errorInfo}, * and depending on the value of {@link #setErrmode} * show nothing, show a warning, or throw an exception. */ public void error(Env env, Throwable exception) { log.log(Level.FINE, exception.ToString(), exception); string errorCode; string errorMessage; int driverError; if (exception instanceof SQLException) { SQLException sqlException = (SQLException)exception; errorCode = sqlException.getSQLState(); errorMessage = sqlException.getMessage(); driverError = sqlException.getErrorCode(); }
public static SQLException getSQLException(string sqlState, string extra) { string reason = getReason(sqlState); SQLException e; if (!string.ReferenceEquals(extra, null)) { e = new SQLException(reason + " : " + extra, sqlState, -99999); } else { e = new SQLException(reason, sqlState, -99999); } return(e); }
/*Questa funzione estrae dal database il codice HTML relativo a una pagina statica con un determinato ID (passato come * parametro URL e lo usa per generare la pagina che poi verrà mostrata all'utente.*/ protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["Id"])) { String idURL = Request.QueryString["Id"]; /*Lo spazio nei parametri URL viene rappresentato con "%20" mentre nel database con " " la sostituzione sottostante permette di * avere lo spazio come rappresentato nel DB in modo da poter effettuare regolarmente la ricerca.*/ query.CommandText = "Select * from PagineH where Id='" + idURL.Replace("%20", " ") + "'"; try { connessione.Open(); riga = query.ExecuteReader(); if (riga.HasRows) { riga.Read(); pagina.InnerHtml = riga["Contenuto"].ToString(); } else { pagina.InnerHtml = "Errore 404: pagina non trovata"; } connessione.Close(); } catch (Exception SQLException) { try { connessione.Close(); } finally { pagina.InnerHtml = SQLException.ToString(); } } } else { Server.Transfer("Default.aspx"); } }
public static IList <SQLException> findRelatedSqlExceptions(Exception exception) { IList <SQLException> sqlExceptionList = new List <SQLException>(); Exception cause = exception; do { if (cause is SQLException) { SQLException sqlEx = (SQLException)cause; sqlExceptionList.Add(sqlEx); while (sqlEx.NextException != null) { sqlExceptionList.Add(sqlEx.NextException); sqlEx = sqlEx.NextException; } } cause = cause.InnerException; } while (cause != null); return(sqlExceptionList); }
internal static SQLException convertException(IOException io, int sqlCode, string sqlState) { SQLException sql = null; if (io is MessageException) { MessageException me = (MessageException)io; Message[] messages = me.Messages; string reason = messages[0].ToString(); sql = new SQLException(reason, sqlState, sqlCode); sql.initCause(io); } else { string reason = io.ToString(); sql = new SQLException(reason, sqlState, sqlCode); sql.initCause(io); } return(sql); }
internal OleDbExceptionImpl(SQLException cause, OleDbConnection connection) : base(cause, connection) { }
internal OleDbExceptionImpl(string message, SQLException cause, OleDbConnection connection) : base(message, cause, connection) { }
internal OracleException(SQLException cause, OracleConnection connection) : base(cause, connection) { }
protected sealed override SystemException CreateException(string message, SQLException e) { return(new OleDbException(message, e, (OleDbConnection)_command.Connection)); }
protected abstract AbstractDbError CreateDbError(SQLException e, AbstractDBConnection connection);
internal SqlException(SQLException cause, SqlConnection connection) : base(cause, connection) { }
internal SqlException(string message, SQLException cause, SqlConnection connection) : base(message, cause, connection) { }
internal OracleException(string message, SQLException cause, OracleConnection connection) : base(message, cause, connection) { }
protected override Exception ThrowExceptionHelper(DbConnection conn, DbCommand comm, Exception innerException) { if (innerException is SQLiteException) { SQLException sqlEx; var ex = innerException as SQLiteException; #if Mono var errorCode = ex.ErrorCode; #else var errorCode = ex.ResultCode; #endif switch (errorCode) { case SQLiteErrorCode.Corrupt: #if Mono case SQLiteErrorCode.NotADatabase: #else case SQLiteErrorCode.NotADb: #endif case SQLiteErrorCode.Perm: #if Mono case SQLiteErrorCode.IOErr: #else case SQLiteErrorCode.IoErr: #endif case SQLiteErrorCode.CantOpen: case SQLiteErrorCode.Full: case SQLiteErrorCode.Auth: { return new FileAccessException(errorCode.ToString(), innerException); } case SQLiteErrorCode.ReadOnly: { sqlEx = new ReadOnlyException(null, innerException); break; } case SQLiteErrorCode.Locked: { sqlEx = new ConnectionException("file is locked", ex); break; } case SQLiteErrorCode.Constraint: { if (innerException.Message.IndexOf("UNIQUE constraint failed", StringComparison.OrdinalIgnoreCase) >= 0) { sqlEx = new UniqueConstraintException(null, innerException); } else { sqlEx = new ConstraintException(null, innerException); } break; } default: { sqlEx = new SQLException(null, innerException); break; } } if (conn != null) { try { sqlEx.ConnectionString = conn.ConnectionString; sqlEx.ConnectionState = conn.State.ToString(); } catch (ObjectDisposedException) { sqlEx.ConnectionState = "Disposed"; } } if (comm != null) { sqlEx.CommandText = comm.CommandText; //newEx.Data.Add("CommandText", comm.CommandText); } return sqlEx; } else { return new ORMException(null, innerException); } }