我试图获得前30天的当前日期和时间..但是,它不是别的东西
new Date(System.currentTimeMillis() - 30 * 24 * 60 * 60 * 1000)
Run Code Online (Sandbox Code Playgroud)
这是回归
Tue Jul 21 04:41:20 IST 2015
Run Code Online (Sandbox Code Playgroud)
有没有错
我正在使用c3p0进行连接池.我已将min连接配置为100,最大大小为2000.我只是编写一个简单的插入程序来检查工作台中有多少连接处于活动状态.但是,我收到以下错误
java.sql.SQLException: Data source rejected establishment of connection, message from server: "Too many connections"
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:650)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1808)
at com.mysql.jdbc.Connection.<init>(Connection.java:452)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:411)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
Run Code Online (Sandbox Code Playgroud)
我的Hibernate.cfg.xml如下
<!-- c3p0 Connection pool config -->
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.min_size">100</property>
<property name="hibernate.c3p0.max_size">2000</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.validate">true</property>
Run Code Online (Sandbox Code Playgroud)
我的Java程序是
public static void main(String[] args) {
// TODO Auto-generated method stub
Transaction tx = null;
SessionFactory factory = HibernateUtil.getSessionFactory();
Session session = factory.openSession();
tx = session.beginTransaction(); …Run Code Online (Sandbox Code Playgroud) 我在单元测试中禁用了 spring Vault。但是,它仍然启用它并在后台运行。这是我的代码。下面的代码有没有问题
@RunWith(SpringRunner.class)
@SpringBootTest(properties = "spring.cloud.vault.enabled=false", classes =
DummyTest.class)
public class DummyTest{
@Test
public void getDummyTest() throws Exception{
assertTrue(true);
}
}
Run Code Online (Sandbox Code Playgroud)
以下是它在控制台中打印的例外情况
Caused by: java.lang.IllegalArgumentException: Token (spring.cloud.vault.token) must not be empty
at org.springframework.util.Assert.hasText(Assert.java:287)
at org.springframework.cloud.vault.config.ClientAuthenticationFactory.createClientAuthentication(ClientAuthenticationFactory.java:108)
at org.springframework.cloud.vault.config.VaultBootstrapConfiguration.clientAuthentication(VaultBootstrapConfiguration.java:206)
at org.springframework.cloud.vault.config.VaultBootstrapConfiguration$$EnhancerBySpringCGLIB$$1d0bfc2.CGLIB$clientAuthentication$3(<generated>)
at org.springframework.cloud.vault.config.VaultBootstrapConfiguration$$EnhancerBySpringCGLIB$$1d0bfc2$$FastClassBySpringCGLIB$$7f75c921.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at org.springframework.cloud.vault.config.VaultBootstrapConfiguration$$EnhancerBySpringCGLIB$$1d0bfc2.clientAuthentication(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 99 more
Run Code Online (Sandbox Code Playgroud) 我正在尝试格式化跨度内的文本.但是,它不起作用.
这是我的HTML
<span class="formatAmount">00000001.00</span>
Run Code Online (Sandbox Code Playgroud)
我的jquery代码
$('.formatAmount').find('span').each(function(i) {
if($.isNumeric($(this).text()))
{
$(this).text(getFormattedAmount($(this).text()));
}
});
Run Code Online (Sandbox Code Playgroud)
它不会首先进入这个循环.代码有什么问题?
提前致谢
我正在动态地在表中添加一个选择选项标签,并在提交时迭代表 tr 以查找 td 中的元素。它将选择标签作为字符串本身返回给我。在这里我无法获得选择标签的选定选项
我的代码是
$('#tableid tbody tr').each(function() {
var countryTag = $(this).find('td:eq(2)').html(); // return the whole select option as string
var selCntry = countryTag.find('option:selected').val(); // this is throwing error.
}
Run Code Online (Sandbox Code Playgroud)
但是在将 select 标签添加到 table 时, selected 属性对任何选项都不可用。
我怎样才能获得所有选定的国家
PS:这篇文章是通过手机制作的。所以可能有错别字
我有一个XML字符串.我正在尝试将该字符串转换为地图,以便我可以获得键和值.但它无法转换.这是我的代码
String xmlString = "<?xml version="1.0" encoding="UTF-8"?><user>
<kyc></kyc>
<address></address>
<resiFI></resiFI></user>"
def convertStringToDocument = {
xmlString ->
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try {
builder = factory.newDocumentBuilder();
org.w3c.dom.Document doc = builder.parse(new InputSource(new StringReader(xmlString)));
return doc;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
def populateDocProofsFromWaiversXML = {
xmlString, mandateFlag ->
final List<DocumentProof> documentProofs = new ArrayList<DocumentProof>();
if (xmlString != null) {
try {
HashMap<String, String> values = new HashMap<String, String>();
Document xml = convertStringToDocument(waiversList);
org.w3c.dom.Node user = xml.getFirstChild(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 jpa 更新一个简单的表。我为它写了一个 jpa 命名查询
@NamedQuery(name="updatedetails",query="update myentity set enddesc=?, startdesc=? Where id=?")
Run Code Online (Sandbox Code Playgroud)
我的代码如下
em.createNamedQuery("updatedetails",myentity.class).serParameter(1, "abcd").serParameter(2,"gjvg").serParameter(3, "gghjj").executeUpdate();
Run Code Online (Sandbox Code Playgroud)
myentity 是我的班级名称
它向我抛出以下错误
Encountered "=" at character but expected ["."] While parsing the query
Run Code Online (Sandbox Code Playgroud)
查询有什么问题吗
我正在尝试List<Map<String, String>>用Java 进行迭代。但是,我无法正确地对其进行迭代。谁能指导我?
Iterator it = list.iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
System.out.println(pairs.getKey() + " = " + pairs.getValue());
}
Run Code Online (Sandbox Code Playgroud)
谢谢,