- 浏览: 220161 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (209)
- database (25)
- java技巧 (25)
- TC总结 (4)
- J2EE (8)
- 算法 (6)
- blog (4)
- php (4)
- linux & mac (19)
- 其它技术 (4)
- javascript&ajax (26)
- 测试技术 (8)
- XML&HTML (2)
- ORM (hibernate ...) (11)
- eclipse (5)
- 技术书籍 (8)
- 项目管理,cmmi (3)
- 硬件技术 (1)
- REST, web service, web架构 (1)
- 卓有成效程序员 (2)
- qone开发 (1)
- Design (4)
- .net (5)
- SCM (4)
- css (23)
- programming languages (1)
- ide (2)
- CSS Patterns (18)
- security (1)
- android (5)
最新评论
-
Virtoway:
说到Angular JS刚读到一片美国构架师的文章关于使用An ...
angular js: angular.bind example -
08284008:
该毛线啊,一点解释的都没有,怎么看
Thread join() 用法 -
Rex86lxw:
在eclipse中我一直用Navigator查看编写代码的,可 ...
eclipse不能自动编译,不报错 -
mistake:
..............
Angular js scope: the child scope would inherit from the parent scope -
sparrow1314:
very good! thanks!
IE下JS调试工具
java 代码
- /**
- * The SQL statement to insert the entity details.
- */
- private static final String INSERT_DETAILS = "INSERT INTO message (message_id, from_handle, project_id, "
- + "project_name, timestamp, subject, message) VALUES (?, ?, ?, ?, ?, ?, ?)" ;
- /**
- * Creates a new database connection using the configured database connection factory and connection name.
- *
- * @return a new database connection created using the configured database connection factory and
- * connection name
- * @throws MessagePersistenceException if an error occurs while creating the connection
- */
- private Connection getConnection() {
- logEntry("getConnection()" );
- Connection conn = null ;
- try {
- this .logExternalCall( "calling connectionFactory.createConnection({0})" , connectionName);
- conn = this .connectionFactory.createConnection(connectionName);
- this .logExternalCall( "returned from connectionFactory.createConnection({0})" , connectionName);
- } catch (DBConnectionException ex) {
- this .throwPersistenceException(ex, "error creating connection: " );
- } finally {
- this .logExit( "getConnection" );
- }
- return conn;
- }
- /**
- * Closes the connection and logs any exception that occurs.
- *
- * @param conn the connection to close (may be null)
- */
- private void closeConnection(Connection conn) {
- this .logEntry( "closeConnection({0})" , conn);
- try {
- if (conn != null ) {
- conn.close();
- }
- } catch (SQLException ex) {
- // this exception doesn't really affect the user, so we'll just log it and continue
- this .logException(ex);
- } finally {
- this .logExit( "closeConnection" );
- }
- }
- /**
- * Closes a prepared statement and logs any exception that occurs.
- *
- * @param statement the prepared statement to close (may be null)
- */
- private void closeStatement(PreparedStatement statement) {
- this .logEntry( "closeStatement({0})" , statement);
- try {
- if (statement != null ) {
- statement.close();
- }
- } catch (SQLException ex) {
- // this exception doesn't really affect the user, so we'll just log it and continue
- this .logException(ex);
- } finally {
- this .logExit( "closeStatement" );
- }
- }
- /**
- * Save an entity with no transaction. Transaction here is handled by the EJB container.
- */
- public void saveEntity(Entity entity) {
- this .checkObject(entity, "entity" );
- this .logEntry( "saveMessage({0})" , entity);
- Connection conn = null ;
- PreparedStatement statement = null ;
- try {
- conn = this .getConnection();
- try {
- statement = conn.prepareStatement(INSERT_DETAILS);
- int pos = 1 ; // work around checkstyle warning about "magic numbers"
- statement.setLong(pos++, entity.getMessageId());
- statement.setString(pos, entity.getText());
- statement.executeUpdate();
- } catch (SQLException ex) {
- this .throwPersistenceException(ex, "error saving message: " );
- }
- } finally {
- this .closeStatement(statement );
- this .closeConnection(conn);
- this .logExit( "saveMessage" );
- }
- }
- /**
- * Save an entity with transaction. When errors occur, we need to roll back the transaction.
- */
- public void saveEntity(Entity entity) {
- this .checkObject(entity, "entity" );
- this .logEntry( "saveMessage({0})" , entity);
- Connection conn = null ;
- PreparedStatement statement = null ;
- try {
- conn = this .getConnection();
- try {
- statement = conn.prepareStatement(INSERT_DETAILS);
- int pos = 1 ; // work around checkstyle warning about "magic numbers"
- statement.setLong(pos++, entity.getMessageId());
- statement.setString(pos, entity.getText());
- statement.executeUpdate();
- } catch (SQLException ex) {
- this .throwPersistenceException(ex, "error saving message: " );
- }
- } finally {
- this .closeStatement(statement );
- this .closeConnection(conn);
- this .logExit( "saveMessage" );
- }
- }
- /**
-
* Creates a
MessagePersistenceException
based on the specified exception, logs it, and - * throws it.
- *
- * @param ex the wrapped exception
- * @param what a description of the operation that failed
-
* @throws MessagePersistenceException a
MessagePersistenceException
wrapping the - * lower-level exception
- */
- private void throwPersistenceException(Throwable ex, String what) {
- // simple helper method, so no logging
- MessagePersistenceException mpe = new MessagePersistenceException(what + ex.getMessage(), ex);
- logException(mpe);
- throw mpe;
- }
发表评论
-
Use Fetch in NHibernate to solve N+1
2014-06-17 14:32 665http://bartwullems.blogspot ... -
SQL where 条件顺序对性能的影响有哪些
2014-05-20 16:31 533SQL where 条件顺序对性能的影响有哪些 http: ... -
function to convert ticks to DatetimeOffset
2013-04-08 17:05 633--function to convert ticks to ... -
The database principal owns a schema in the database, and cannot be dropped
2012-08-06 15:53 755http://blog.sqlauthority. ... -
sql server function example to find managed employees
2012-08-04 11:44 808Prepare data: USE AdventureWor ... -
SQL Server Isolation Levels By Example
2012-07-27 22:02 877To check the current database i ... -
logical read vs physical read
2012-07-12 11:15 854Introduction Normally, ... -
安装sql server adventureworks2008
2012-07-08 22:21 663直接使用下载的.exe文件 安装总是得到以下错误: “a ... -
Active record: Transaction VS SessionScope
2011-11-28 23:00 712http://www.mail-archive.c ... -
How to use session per scope in Castle ActiveRecord
2011-11-26 22:50 542http://www.castleproject.org/ac ... -
mysql 导入.sql文件命令
2009-11-23 13:41 1293mysql -u"root" -p& ... -
数据库中查看已经创建了地索引
2009-06-04 17:50 747mysql: SHOW {INDEX | INDEXES | ... -
sql join( inner join, outer join) 分析
2009-04-03 09:58 839举例做了一个比较详细的inner join, outer jo ... -
jdbc连接一定要关闭connection, resultset和preparedstatement
2008-11-10 17:43 6973今天写了个程序往数据库插入100万条记录,代码如下 publi ... -
jboss和oracle端口冲突
2008-06-03 19:11 1150Both JBoss and Oracle RDBMS are ... -
Oracle XE安装及PL/SQL连接
2007-11-07 10:59 2646安装Oracle XE or 企业版。 需要安装cli ... -
外连接
2007-09-29 13:38 964如果要从boys, girls两张表中查住在同一个城市的男孩和 ... -
JDBC访问数据库
2007-09-19 15:53 865java 代码 Class.forNam ... -
Levenshtein Distance Algorithm: Oracle PL/SQL Implementation
2007-08-19 17:11 1618Levenshtein Distance Algorithm: ... -
jpa技术总结
2007-06-22 10:00 1831jpa是ejb的基础。现在ejb还没入门呢,但一定要学下去。从 ...
相关推荐
第1部分 介绍数据库、SQL和JDBC 第1章 关系型数据库 1.1 理解关系型数据库管理系统 1.1.1 关系模型 1.1.2 Codd法则 1.1.3 表、行、列和关键字 1.1.4 主键 1.1.5 外键 1.1.6 关系 1.1.7 视图 1.1.6 范式...
在使用maven开发web项目极大地方便了jar包的依赖,在测试时也可以集成Servlet容器,从启动速度和量级上看,Jetty无疑是不二选择,然而从8.x开始,如果你的web项目中不包含数据库访问(或者说没有事务管理器)的话,...
之前一直找原因,最后知道了解决方法,具体请下载源码查看。特别是用到throw的事务中
JTA(Java Transaction API)允许应用程序执行分布式事务处理--在两个或多个网络计算机资源上访问并且更新数据。JDBC驱动程序的JTA支持极大地增强了数据访问能力。本文的目的是要提供一个关于的Java事务处理API(JTA)...
Java JTA 与 JDBC 类似,也是 Java 中的一种规范,JDBC 定义了 Java 应用程序如何访问数据库,而 JTA 则定义 Java 应用程序如何实现分布式事务。 Java 中与数据库相关的技术还包括 JPA,它们都分别提供了一套事务 ...
第1部分 介绍数据库、SQL和JDBC 第1章 关系型数据库 1.1 理解关系型数据库管理系统 1.1.1 关系模型 1.1.2 Codd法则 1.1.3 表、行、列和关键字 1.1.4 主键 1.1.5 外键 1.1.6 关系 1.1.7 视图 1.1.6 范式...
第1部分 介绍数据库、SQL和JDBC 第1章 关系型数据库 1.1 理解关系型数据库管理系统 1.1.1 关系模型 1.1.2 Codd法则 1.1.3 表、行、列和关键字 1.1.4 主键 1.1.5 外键 1.1.6 关系 1.1.7 视图 1.1.6 范式...
第1部分 介绍数据库、SQL和JDBC 第1章 关系型数据库 1.1 理解关系型数据库管理系统 1.1.1 关系模型 1.1.2 Codd法则 1.1.3 表、行、列和关键字 1.1.4 主键 1.1.5 外键 1.1.6 关系 1.1.7 视图 1.1.6 范式...
在sqlserver中如何清空数据库日志文件:当您备份一个很大的数据库时,日志对您无用时,您可以清空其日志。
sql2java是一个轻量级数据库(SQL)访问代码(java)生成器,是在国外一款同名开源项目的基础上重写的ORM工具,以maven 插件方式运行,目前在mysql下测试通过已经应用于实际项目开发中。生成的表记录的java bean类支持...
sql数据库日志已满的解决办法
如何在数据库中用好Transaction?在ASP的实际操作中,总会发生这样的情况,如在银行,从我的帐户往费文华的帐户划款,我的帐户显示已经划出,但因银行的系统出现故障,导致费文华帐户的数据库更改失败,这应该怎样...
英文版,关于事务设计策略 Local Transaction Programmatic Transaction Declarative Transaction XA Transaction Transaction Designe Pattern ....
执行sql 语句,中间没有用到临时表 提示服务器: 消息 9002,级别 17,状态 2,行 1 数据库 'tempdb' 的日志已满。请备份该数据库的事务日志以释放一些日志空间...DUMP TRANSACTION dbname WITH NO_LOG 截断事务日志命
内容概述:SQL Server数据库相关内容,对应张磊著《SQL Server数据库应用技术项目化教程》中166页(3)ROLLBACK TRANSACTION将显式事务或隐式事务回滚到事务的结束所对应的源码。代码经个人运行后无误,如果下载后运行...
java.sql 提供使用 JavaTM 编程语言访问并处理存储在数据源(通常是一个关系数据库)中的数据的 API。 java.text 提供以与自然语言无关的方式来处理文本、日期、数字和消息的类和接口。 java.text.spi java.text ...
Java Transaction Design Strategies.pdf 事务设计的好书 无口令版本,可打印
适合初学java者的联系内容,不过给的是包,要运行跑起来的话环境是要自己建好的。
JAVA网络编程资料(4)-相关API—Java Transaction API概述(1).chm
包含 SqlServer Mysql Access 。。。。等驱动都有。