use of lucee.runtime.db.DatasourceConnection in project Lucee by lucee.
the class DatasourceResourceProvider method setLastModified.
public boolean setLastModified(ConnectionData data, int fullPathHash, String path, String name, long time) {
try {
Attr attr = getAttr(data, fullPathHash, path, name);
DatasourceConnection dc = getDatasourceConnection(data);
try {
getCore(data).setLastModified(dc, data.getPrefix(), attr, time);
} finally /*catch (SQLException e) {
return false;
} */
{
removeFromCache(data, path, name);
release(dc);
// manager.releaseConnection(CONNECTION_ID,dc);
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
return false;
}
return true;
}
use of lucee.runtime.db.DatasourceConnection in project Lucee by lucee.
the class DatasourceResourceProvider method getInputStream.
public InputStream getInputStream(ConnectionData data, int fullPathHash, String path, String name) throws IOException {
Attr attr = getAttr(data, fullPathHash, path, name);
if (attr == null)
throw new IOException("file [" + path + name + "] does not exist");
DatasourceConnection dc = null;
try {
dc = getDatasourceConnection(data);
return getCore(data).getInputStream(dc, data.getPrefix(), attr);
} catch (SQLException e) {
throw new IOException(e.getMessage());
} catch (PageException e) {
throw new PageRuntimeException(e);
} finally {
release(dc);
// manager.releaseConnection(CONNECTION_ID,dc);
}
}
use of lucee.runtime.db.DatasourceConnection in project Lucee by lucee.
the class DatasourceResourceProvider method _getAttr.
private Attr _getAttr(ConnectionData data, int fullPathHash, String path, String name) throws PageException {
if (!StringUtil.isEmpty(data.getDatasourceName())) {
DatasourceConnection dc = null;
try {
dc = getDatasourceConnection(data);
Attr attr = getCore(data).getAttr(dc, data.getPrefix(), fullPathHash, path, name);
if (attr != null)
return putToCache(data, path, name, attr);
} catch (SQLException e) {
throw new DatabaseException(e, dc);
} finally {
getManager().releaseConnection(ThreadLocalPageContext.get(), dc);
}
}
return putToCache(data, path, name, Attr.notExists(name, path));
}
use of lucee.runtime.db.DatasourceConnection in project Lucee by lucee.
the class MySQL method writeInsert.
private void writeInsert(DatasourceConnection dc, String prefix, Attr attr, InputStream is) throws SQLException {
PreparedStatement stat1 = null;
Statement stat2 = null;
PreparedStatement stat3 = null;
ResultSet rs = null;
try {
// Insert
String sql = "insert into " + prefix + "data (rdr_data) values(?)";
log(sql);
Connection conn = dc.getConnection();
stat1 = dc.getConnection().prepareStatement(sql);
stat1.setBinaryStream(1, is, -1);
stat1.execute();
// select
sql = "select rdr_id,Length(rdr_data) as DataLen from " + prefix + "data order by rdr_id desc LIMIT 1";
log(sql);
stat2 = conn.createStatement();
rs = stat2.executeQuery(sql);
// update
if (rs.next()) {
sql = "update " + prefix + "attrs set rdr_data=?,rdr_length=? where rdr_id=?";
log(sql);
stat3 = dc.getConnection().prepareStatement(sql);
stat3.setInt(1, rs.getInt(1));
stat3.setInt(2, rs.getInt(2));
stat3.setInt(3, attr.getId());
stat3.executeUpdate();
}
} finally {
DBUtil.closeEL(rs);
DBUtil.closeEL(stat1);
DBUtil.closeEL(stat2);
}
}
Aggregations