我的Hibernate下有MySQL,我也使用c3p0-0.9.1连接池.
在笔记本电脑上运行时(我的意思是在本地)我没有错误.但是当我在服务器上部署它时,我得到了这个异常:
com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
Run Code Online (Sandbox Code Playgroud)
这是我的堆栈跟踪:
root cause
com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:78)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1463)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:616)
org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:344)
$Proxy8.beginTransaction(Unknown Source)
com.hposg.domain.HPOSG.getItstance(HPOSG.java:56)
com.hposg.domain.Game.<init>(Game.java:43)
com.hposg.domain.GlobalGame.<init>(GlobalGame.java:12)
com.hposg.domain.SiteAdmin.createNewGame(SiteAdmin.java:18)
com.hposg.controller.struts.InitializingAction.execute(InitializingAction.java:45)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:616)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) …Run Code Online (Sandbox Code Playgroud) 我最近升级到Lion,一切都很好.甚至重启机器几次.然后在周末,Rails走了!我的所有宝石都没了.我发誓我不知道发生了什么.它工作得很好.
仔细观察后,RVM本身就消失了.
所以,我重新安装RVM并尝试安装Ruby 1.9.2并得到此错误日志:
[2011-08-08 14:30:41] ./configure --prefix="/Users/cbmeeks/.rvm/usr"
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... no
configure: error: in `/Users/cbmeeks/.rvm/src/yaml-0.1.4':
configure: error: C compiler cannot create executables
See `config.log' for …Run Code Online (Sandbox Code Playgroud) 假设我有一个类似的存储库:
public interface MyRepository extends PagingAndSortingRepository<MyEntity, String> {
@Query("....")
Page<MyEntity> findByCustomField(@Param("customField") String customField, Pageable pageable);
}
Run Code Online (Sandbox Code Playgroud)
这非常有效.但是,如果客户端发送已形成的请求(例如,搜索不存在的字段),则Spring将异常作为JSON返回.揭示@Query等等
// This is OK
http://example.com/data-rest/search/findByCustomField?customField=ABC
// This is also OK because "secondField" is a valid column and is mapped via the Query
http://example.com/data-rest/search/findByCustomField?customField=ABC&sort=secondField
// This throws an exception and sends the exception to the client
http://example.com/data-rest/search/findByCustomField?customField=ABC&sort=blahblah
Run Code Online (Sandbox Code Playgroud)
抛出并发送给客户端的异常示例:
{
message:null,
cause: {
message: 'org.hibernate.QueryException: could not resolve property: blahblah...'
}
}
Run Code Online (Sandbox Code Playgroud)
我该如何处理这些例外情况?通常,我使用的@ExceptionHandler是我的MVC控制器,但我没有使用Data Rest API和客户端之间的层.我是不是该?
谢谢.
java exception-handling spring-data spring-data-jpa spring-data-rest
我似乎无法找到这些信息.但是使用地理搜索你可以指定$maxDistance但是对于我的生活,我无法找到它是英里,公里等.
这是我正在使用的示例查询:
db.hotels.find( { location: { $near : [18.74255, 99.03523], $maxDistance : 0.05 } } ).count()
Run Code Online (Sandbox Code Playgroud)
返回15(来自我的酒店数据库).
感谢您提供任何信息.
假设我的HTML文档如下:
<div class="headline">News</div>
<p>Some interesting news here</p>
<div class="headline">Sports</div>
<p>Baseball is fun!</p>
Run Code Online (Sandbox Code Playgroud)
我可以headline使用以下代码获取div:
require 'rubygems'
require 'nokogiri'
require 'open-uri'
url = "mypage.html"
doc = Nokogiri::HTML(open(url))
doc.css(".headline").each do |item|
puts item.text
end
Run Code Online (Sandbox Code Playgroud)
但是如何访问以下p标记中的内容以便News与之相关Some interesting news here?
我见过很多例子com.mycompany.someapp.似乎是域的反面.这对我来说真的很有意义.
但在一天结束时,它真的重要吗?我们是一家小商店,所以也许我们没有看到正确域名命名的好处.
那么,将它命名为与域匹配是一种好习惯吗?如果是这样,为什么?
我认为socket.io的重点是不必担心现代浏览器?大声笑
无论如何,我是socket编程的新手.我有一个小应用程序,只是模仿鼠标移动.
您打开了几个浏览器,当您移动鼠标时,您的操作将记录在其他浏览器中.它移动一个小方块.有点酷.但是,当我在iPad(iOS6)上打开它时什么都没有!套接字没有连接.我甚至在connect活动中发出警报信息,什么都没有.
在我的笔记本电脑上使用IE,FF和Chrome就好了.唯一的区别是我的开发机器localhost在iPad使用机器的IP时使用.但是,当我在笔记本电脑上连接到我的本地IP时,它仍然有效.只是不在Safari/iPad中.
这是我的服务器.
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
fs = require('fs');
app.listen(80);
function handler(req, res) {
var file = __dirname + '/public/index.html';
fs.readFile(file,
function(err, data) {
if(err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
}
);
}
var rooms = ['abc', 'test1'];
var sockets = [];
io.sockets.on('connection', function(socket) {
sockets.push(socket);
socket.on('m', function(data) {
socket.broadcast.to(socket.room).emit('relay', {msg: 'MouseX: ' + data.x + ' MouseY: ' + data.y, x: data.x, y: data.y});
}); …Run Code Online (Sandbox Code Playgroud) 你认为使用EC2实例(Micro,64bit)对MongoDB副本集有好处吗?
看起来如果这就是他们所做的一切,并且有超过600兆的RAM,人们可以使用它们来获得一个不错的设置.
此外,他们也会制作好的主(写)服务器吗?
我的数据库现在只有1-2演出,但我看到它今年增长到20-40演出(希望如此).
谢谢
所以,我有这个场景,我需要获取标题记录,删除它的详细信息,然后以不同的方式重新创建详细信息.更新细节会非常麻烦.
我基本上有:
@Transactional
public void create(Integer id, List<Integer> customerIDs) {
Header header = headerService.findOne(id);
// header is found, has multiple details
// Remove the details
for(Detail detail : header.getDetails()) {
header.getDetails().remove(detail);
}
// Iterate through list of ID's and create Detail with other objects
for(Integer id : customerIDs) {
Customer customer = customerService.findOne(id);
Detail detail = new Detail();
detail.setCustomer(customer);
header.getDetails().add(detail);
}
headerService.save(header);
}
Run Code Online (Sandbox Code Playgroud)
现在,数据库具有如下约束:
Header
=================================
ID, other columns...
Detail
=================================
ID, HEADER_ID, CUSTOMER_ID
Customer
=================================
ID, other columns...
Constraint: …Run Code Online (Sandbox Code Playgroud) 所以我正在使用ExtJS 4.1.我有一个包含两个项目的视口.它们堆叠正确但我想在它们之间留出一些空间.边距似乎不起作用.
var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
Ext.onReady(function() {
Ext.QuickTips.init();
window.formPanel = Ext.widget({
bodyPadding: '5 5 0',
collapsible: false,
defaultType: 'textfield',
frame: true,
id: 'formPanel',
layout: 'form',
renderTo: '',
title: 'Spring Demo 3 (Lookup Transfer Request)',
url: contextPath + '/users/ajax',
width: 450,
xtype: 'form',
buttons: [{
text: 'Check Status',
scope: this,
handler: function() {
formPanel.getForm().submit({
success: function(res, req) {
}
});
}
}],
fieldDefaults: {
msgTarget: 'side',
labelWidth: 105
},
items: [{
afterLabelTextTpl: required,
allowBlank: false,
fieldLabel: 'Username',
name: …Run Code Online (Sandbox Code Playgroud) java ×4
mongodb ×2
ruby ×2
amazon-ec2 ×1
c3p0 ×1
extjs4 ×1
geospatial ×1
hibernate ×1
ios6 ×1
jpa ×1
mysql ×1
node.js ×1
nokogiri ×1
osx-lion ×1
performance ×1
persistence ×1
rvm ×1
socket.io ×1
spring ×1
spring-data ×1