我想使用socket.io将数据从服务器推送到浏览器,但项目是java tomcat,并且在Github中有很多实现服务器的实现socket.io.他们中的大多数人说他们已被弃用或者有更好的可用.任何人都可以建议我一个好的实施.
我看到很多关于广播的演示和示例代码socket.io.我的要求是将不同的消息推送给不同的客户端.有人能指点我一些好的演示或教程来处理这些东西吗?
谢谢
我在mybatis上使用mysql,我在我们的实时服务器上遇到这个错误
com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@6538f8f2
-- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
Run Code Online (Sandbox Code Playgroud)
我不明白为什么这个错误会因为我的C3P0设置而来?我的C3P0设置是这样的
----开始更新-----
下面是我的spring-servlet.xml配置
我将 datasource bean 更新为
<bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close" p:driverClass="com.mysql.jdbc.Driver"
p:jdbcUrl="jdbc:mysql://localhost/jdb" p:user="root" p:password="root"
p:acquireIncrement="10"
p:idleConnectionTestPeriod="60"
p:maxPoolSize="100"
p:maxStatements="0"
p:minPoolSize="10"
p:initialPoolSize="10"
p:statementCacheNumDeferredCloseThreads="1" />
<!-- Declare a transaction manager -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="datasource" />
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="datasource" />
</bean>
<!-- scan for mappers and will automatically scan the whole classpath for xmls -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
<property name="basePackage" value="com.mycom.myproject.db.mybatis.dao" /> …Run Code Online (Sandbox Code Playgroud) 我试图在MS-SQL数据库中插入一个变量当前的日期和时间.我用这种格式:
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Calendar cal = Calendar.getInstance();
System.out.println(dateFormat.format(cal.getTime()));
Run Code Online (Sandbox Code Playgroud)
我得到了这个结果2013-01-28 09:29:37.941
我定义了数据库中的字段,datetime正如我在其他具有相同字段的表中看到的那样,日期和时间的编写方式与2011-07-05 14:18:33.000完全相同.
我尝试使用我在java程序中执行的查询插入数据库,但是我收到此错误
SQL异常:状态:S0003消息:将varchar数据类型转换为值的日期时间数据类型超出范围.错误:242
我的查询是这样的:
query = "INSERT INTO Companies CreatedOn"+
"VALUES ('" + dateFormat.format(cal.getTime()) + "')"
Run Code Online (Sandbox Code Playgroud)
但我不明白我做错了什么.
我有2200万条记录的大桌子.我想执行下一个查询:
select auto_alerts from alerts_stat where endDate > "2012-12-01"
Run Code Online (Sandbox Code Playgroud)
为了提高性能,我为endData字段添加了BTREE索引:
CREATE INDEX endDate_index USING BTREE ON alerts_stat(endDate)
Run Code Online (Sandbox Code Playgroud)
在我开始分析查询执行计划之后:
当我想在15到7天之前获取参数时:
explain select alerts_sp from alerts_stat
where endDate between CURDATE() - 15 and CURDATE() - 7;
Run Code Online (Sandbox Code Playgroud)
我有下一个执行计划来处理2,762,088行.
'1', 'SIMPLE', 'browser_plugin_alerts_stat', 'range', 'endDate_index', 'endDate_index', '4', NULL, '2762088', 'Using where'
Run Code Online (Sandbox Code Playgroud)
当我将间隔增加一天时,我收到了:
explain select alerts_sp from alerts_stat
where endDate between CURDATE() - 15 and CURDATE() - 6;
Run Code Online (Sandbox Code Playgroud)
EXPLAIN表示MySQL计划处理所有22,923,126行.
'1', 'SIMPLE', 'browser_plugin_alerts_stat', 'ALL', 'endDate_index', NULL, NULL, NULL, '22932390', 'Using where'
Run Code Online (Sandbox Code Playgroud)
例如,在WHERE过程22,925,642中没有任何条件地选择.
我可以改进执行计划吗?也许我在某个地方有错误,或者是正常的MySQL行为?
mysql performance database-performance sqldatetime database-indexes
我需要通过Hibernate将许多实体插入到数据库中.所以,我想找到最有效的Id生成算法.
因此,Hibernate Documentation存在四种广泛使用的生成策略:
我应该使用MySQL数据库,所以我不能应用SEQUENCE生成策略.其他策略怎么样?从性能的角度来看效率最高的是什么?
使用 Hibernate 和 Spring Social,
我正在尝试通过电子邮件地址查询数据库。当我执行此查询时:
公共帐户 findAccountByUsername(String 用户名) {
Run Code Online (Sandbox Code Playgroud)Session session = sessionFactory.getCurrentSession(); String selectQuery = "FROM Account as account WHERE account.username = "+username; Query query = session.createQuery(selectQuery); @SuppressWarnings("unchecked") List<Account> results = query.list(); if (!results.iterator().hasNext()) return null; return results.iterator().next(); }
我得到这个异常
2013-01-22 14:37:13,090 [DEBUG] [HibernateTransactionManager,doBegin(),569] - 将 Hibernate 事务公开为 JDBC 事务 [com.mchange.v2.c3p0.impl.NewProxyConnection@3b249bb2] 2013-01-22 14 :37:13,352 [DEBUG] [QueryTranslatorImpl,parse(),272] - parse() - HQL:来自masterPackage.model.orm.Account作为帐户,其中account.username = myEmail@gmail.com 2013-01-22 14: 37:13,383 [DEBUG] [AbstractPlatformTransactionManager,processRollback(),843] - 启动事务回滚 2013-01-22 14:37:13,384 [DEBUG] [HibernateTransactionManager,doRollback(),672] - 回滚会话上的 Hibernate 事务 [org …
import java.util.HashMap;
import java.util.Map;
public class StackOverFlowQuestion {
private static final int ERROR_CODE100 = -100;
private static final int ERROR_CODE101 = -101;
private static final int ERROR_CODE102 = -102;
private static final int ERROR_CODE103 = -103;
private static final int ERROR_CODE104 = -104;
public enum ErrorDetails {
ERROR_CODE_100(ERROR_CODE100, "Error code 100 Desc", false),
ERROR_CODE_101(ERROR_CODE101, "Error code 101 Desc", false),
ERROR_CODE_102(ERROR_CODE102, "Error code 102 Desc", true),
ERROR_CODE_103(ERROR_CODE103, "Error code 103 Desc", false),
ERROR_CODE_104(ERROR_CODE104, "Error code 104 Desc", true);
private int errorCode; …Run Code Online (Sandbox Code Playgroud) 公地io代码:
String resultURL = String.format(GOOGLE_RECOGNIZER_URL, URLEncoder.encode("hello", "UTF-8"), "en-US");
URI uri = new URI(resultURL);
byte[] resultIO = IOUtils.toByteArray(uri);
Run Code Online (Sandbox Code Playgroud)
我有这个例外:
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://translate.google.cn/translate_tts?ie=UTF-8&q=hello&tl=en-US&total=1&idx=0&textlen=3
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:654)
at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:635)
at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:617)
at com.renren.intl.soundsns.simsimi.speech.ttsclient.impl.GoogleTTSClient.main(GoogleTTSClient.java:70)
Run Code Online (Sandbox Code Playgroud)
但是当我使用httpclient时,结果还可以。
String resultURL = String.format(GOOGLE_RECOGNIZER_URL, URLEncoder.encode(text, "UTF-8"), "en-US");
HttpClient client = new HttpClient();
GetMethod g = new GetMethod(resultURL);
client.executeMethod(g);
byte[] resultByte = g.getResponseBody();
Run Code Online (Sandbox Code Playgroud)
这是怎么发生的?
提前致谢 :)
Maven的依赖:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我在WPF桌面应用程序中遇到以下问题时遇到问题:
我从后面的代码动态创建TextBlocks并将它们插入到StackPanel中.这项工作到目前为止.当用户将鼠标移到TextBlock上时,Strikthrough将应用于文本块,表示可以通过单击删除该项目.同样,这仍然有效.当鼠标离开文本块时,删除删除线,这里抛出异常,说IsFrozen必须设置为false才能更改TextDecorationCollection对象.我无法弄清楚如何解决这个问题.
这是我的代码:
private void HandleAddedSecondaryDxMouseEnter(Object sender, MouseEventArgs e) {
TextBlock tbl = (TextBlock)sender;
tbl.TextDecorations = TextDecorations.Strikethrough;
}
private void HandleAddedSecondaryDxMouseLeave(Object sender, MouseEventArgs e) {
TextBlock tbl = (TextBlock)sender;
tbl.TextDecorations.Remove(tbl.TextDecorations[0]);
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
谢谢,伯恩德
我正在发送一个包含模型的自定义对象列表,以及一个JSP作为视图.我的自定义对象有一个名为的属性properties,它是JSONObject.此属性的值为
{"services":[{"name":"abcd"},{"name":"efgh"}]}
Run Code Online (Sandbox Code Playgroud)
现在我想迭代JSONArray [{"name":"abcd"},{"name":"efgh"}].这是我正在做的循环
<c:if test="${not empty customObject.services}">
<c:forEach items="${customObject.services.getJSONArray(\"services\")}" var="Service" varStatus="rowCounterCh">
<li>${Service.name}</li>
</c:forEach>
</c:if>
Run Code Online (Sandbox Code Playgroud)
但是这不能遍历JSONArray.我得到了以下错误.
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
Run Code Online (Sandbox Code Playgroud)
那么,我应该怎么做才能遍历JSONArray?请帮忙
java ×8
mysql ×3
hibernate ×2
jdbc ×2
performance ×2
spring ×2
.net ×1
arrays ×1
c# ×1
collections ×1
datetime ×1
hql ×1
http ×1
httpclient ×1
json ×1
jstl ×1
mybatis ×1
socket.io ×1
sql ×1
sql-server ×1
sqldatetime ×1
wpf ×1