User Defined Type as Table Column

2014-11-27 Thread kosurusekhar
Hi folks,

We decided to create a table column with User Defined Type (A java class has
big byte array  certain other properties), Is there any issues or any
problems (performance side) while doing insert / update / delete into or
from this table?

If any body come across this kind of scenario means please suggest me with
your inputs.


Regards
Sekhar.



--
View this message in context: 
http://apache-database.10148.n7.nabble.com/User-Defined-Type-as-Table-Column-tp143321.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: Locks on crashed database

2014-11-27 Thread Peter Ondruška
Dear Knut,

many thanks for the tip. For others who need something similar here is the
complete code:

package xarecovery;

import java.sql.SQLException;
import java.util.logging.Level;

import javax.sql.XAConnection;
import javax.sql.XADataSource;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;

import org.apache.derby.jdbc.EmbeddedDataSource;
import org.apache.derby.jdbc.EmbeddedXADataSource;

/**
 * Remove obsolete lock records caused by not gracefully removing database
that was under transaction manager control.br /
 * This can be observed by having records in TRANSACTION_TABLE (and related
in LOCK_TABLE) with state PREPARED:br /
 * SELECT * FROM SYSCS_DIAG.LOCK_TABLE;br /
 * SELECT * FROM SYSCS_DIAG.TRANSACTION_TABLE;
 *
 * @author Knut Anders Hatlen, Peter Ondruška (just slightly modified)
 *
 */
public class Recover {

  private static final java.util.logging.Logger LOGGER =
java.util.logging.Logger.getLogger(Recover.class.getName());

  public static void main(final String[] args) {

final EmbeddedDataSource eds = new EmbeddedXADataSource();
eds.setDatabaseName(pathtodatabase);

final XADataSource ds = (EmbeddedXADataSource) eds;

try {
  final XAConnection xac = ds.getXAConnection();
  final XAResource xar = xac.getXAResource();
  for (final Xid xid : xar.recover(XAResource.TMSTARTRSCAN)) {
LOGGER.log(Level.INFO, Recover using rollback Xid {0},
xid.toString());
xar.rollback(xid);
  }
  xac.close();
} catch (final SQLException | XAException e) {
  LOGGER.log(Level.WARNING, null, e);
}

try {
  eds.setShutdownDatabase(shutdown);
  eds.getConnection();
} catch (final SQLException e) {
  LOGGER.log(Level.INFO, This exception is OK, e);
}

  }

}


On 25 November 2014 at 12:49, Knut Anders Hatlen knut.hat...@oracle.com
wrote:

 Peter Ondruška peter.ondru...@kaibo.eu writes:

  Dear all,
 
  I have a database that has locks in SYSCS_DIAG.LOCK_TABLE. How do I
  remove those locks? I restarted the database but the locks are still
  there. SYSCS_DIAG.TRANSACTION_TABLE also has related record with
  status PREPARED. This database was used with XA on application server
  but it was removed for troubleshooting.

 Hi Peter,

 You probably need to run XA recovery and commit or roll back the
 prepared transactions. Something like this:

 XADataSource ds = ;
 XAConnection xac = ds.getXAConnection();
 XAResource xar = xac.getXAResource();
 for (Xid xid : xar.recover(XAResource.TMSTARTRSCAN)) {
 xar.rollback(xid);
 // or, if you prefer, xar.commit(xid, false);
 }

 Hope this helps,

 --
 Knut Anders




-- 
Peter Ondruška


Re: User Defined Type as Table Column

2014-11-27 Thread Rick Hillegas

On 11/27/14 3:56 AM, kosurusekhar wrote:

Hi folks,

We decided to create a table column with User Defined Type (A java class has
big byte array  certain other properties), Is there any issues or any
problems (performance side) while doing insert / update / delete into or
from this table?

If any body come across this kind of scenario means please suggest me with
your inputs.


Regards
Sekhar.

Hi Sekhar,

I don't know of any INSERT/UPDATE/DELETE performance problems. However, 
UDTs are not indexable by themselves, which may give you performance 
problems when you SELECT them. One workaround is to add a generated 
column to extract an indexable key out of the UDT.


Hope this helps,
-Rick



--
View this message in context: 
http://apache-database.10148.n7.nabble.com/User-Defined-Type-as-Table-Column-tp143321.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.





Re: User Defined Type as Table Column

2014-11-27 Thread kosurusekhar
Hi Rick,

Thanks for the reply.

Actually I have another column which we are using as foreign key, so index
issue may not be occur. I will be do all kind of operations based this
column. My doubt is I read in derby sites that, Blob columns will bit slower
to delete. I hope these UDT's also kind of Blob type.


Regards
Sekhar.



--
View this message in context: 
http://apache-database.10148.n7.nabble.com/User-Defined-Type-as-Table-Column-tp143321p143326.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.