[Persistence, JBoss/CMP, Hibernate, Database] - problem streaming data to a blob on an sqlserver
by hugin78
I have an entity with a lob value:
| @Lob
| public byte[] getData() {
| return data;
| }
|
I have a large amount of data that Iretrieve in small parts from the database, convert it to xml and stream it to the blobfield.
| public void insertData() throws Exception {
| Context ctx = new InitialContext();
| DataSource ds = (DataSource) ctx.lookup("java:/UdtraekDS");
| Connection connection = ds.getConnection();
|
| try {
| if (connection != null) {
| String readStatementBlobStreamOracle = "select data from as_udtraek where name = ? for update";
| String readStatementBlobStreamSQLServer = "select data from as_udtraek (UPDLOCK) where name = ?";
| // Select sql depends on the database
| String sql = Util.isOracle() ? readStatementBlobStreamOracle : readStatementBlobStreamSQLServer;
|
| PreparedStatement ps = connection.prepareStatement(sql);
| ps.setString(1, "allekatalogydelser.xml");
|
| ResultSet res = ps.executeQuery();
| if (res.next()) {
| Blob val = res.getBlob(1);
| OutputStream outputStream = val.setBinaryStream(1);
| logger.info("Writing data to blob");
| // Lots of data will be generated here and written to the outputstream
|
| // For test
| outputStream.write("testing".getBytes());
|
| outputStream.flush();
| outputStream.close();
| }
|
| res.close();
| ps.close();
| }
| } catch (Exception e) {
| logger.error(1, e);
| } finally {
| try {
| connection.close();
| } catch (SQLException e) {
| logger.warn("could not close the connection", e);
| }
| }
| }
|
In the example above I retrieve the existing AS_UDTRAEK entity with the name "allekatalogydelser.xml? and write the text ?testing? to the blobfield. This works perfectly well with an oracle db but with a Microsoft SQL server 9 no data is written to the blob and no exception is thrown.
Can anyone tell me what I'm doing wrong.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4014846#4014846
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4014846
19Â years, 2Â months
[JBoss Portal] - Re: Deploy new portal using existing portlets
by dleerob
I created a new instance of CMSPortlet through the actual portal by going to the Management Portlet, clicking on "portlets", selecting "local.portal.CMSAdminPortlet", then on the right entering in a new name, and clicking "Create instance". If you now click on "Instances" under the Management Portlet, your new instance should be there. You can edit the indexpage value from there to point to the new contents index page that you should create under the CMS Admin. I basically created a [mycompanyname] folder at the same level as the default folder, stuck an index.html file in there and created whatever contents I wanted, and then pointed my new instance indexpage value to that directory/file. Now you can add your new instance to whatever pages you want and give the required securities via the Management Portal "Portal" link.
Hope this help you a bit.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4014845#4014845
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4014845
19Â years, 2Â months
[EJB 3.0] - NullPointerException with EntutyManager.createNamedQuery
by guava
Hi,
I'm getting a NullPointerException when calling the createNamedQury() under Jboss 4.0.5GA. Anyone one knows what the stack trace means?
22:25:41,609 ERROR [STDERR] Exception in thread "pool-5-thread-1"
22:25:41,609 ERROR [STDERR] java.lang.NullPointerException
22:25:41,609 ERROR [STDERR] at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getNonTxEntityManager(ManagedEntityManagerFactory.java:59)
22:25:41,609 ERROR [STDERR] at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getTransactionScopedEntityManager(ManagedEntityManagerFactory.java:164)
22:25:41,609 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManager.createNamedQuery(TransactionScopedEntityManager.java:132)
22:25:41,609 ERROR [STDERR] at coco.nms.router.RouterManager.getRouter(Route
rManager.java:215)
My POJO looks like the following:
@Entity
@Table(name = "ROUTER")
@org.hibernate.annotations.Table(appliesTo="ROUTER", indexes = { @Index(name="router_mac_index", columnNames = { "MAC" } ) } )
@NamedQuery(name = "nms.Router.by.mac", query = "from Router r where r.mac = :mac")
public class Router {
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4014833#4014833
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4014833
19Â years, 2Â months