有一个名为contacts列的表id, name, address, ph_no等.
我需要查找具有相同name行的行,如果行计数大于1,则显示这些行.
例如:
表:contacts
id--------name--------address---------ph_no--------
111 apple U.K 99*******
112 banana U.S 99*******
123 grape INDIA 99*******
143 orange S.AFRICA 99*******
152 grape KENYA 99*******
Run Code Online (Sandbox Code Playgroud)
对于上面的表,我需要获得具有相同列name数据的行,如下所示:
id--------name--------address---------ph_no--------
123 grape INDIA 99*******
152 grape KENYA 99*******
Run Code Online (Sandbox Code Playgroud)
我需要根据名称获取行作为参数,如下面的example语法:
select * from contacts where name='grape' and it's count(*) >1 return those rows.
Run Code Online (Sandbox Code Playgroud)
如何实现上述问题的解决方案.
我正在测试/切换到Java EE7(Glassfish 4),我遇到的一个问题是拦截器,每当我尝试运行项目时,我都会收到以下错误.
严重:加载应用程序时出现异常:CDI部署失败:WELD-001417文件中启用拦截器类com.xxxxxx.security.SecuredInterceptor:/home/xxxxxx/xxxxxx/target/xxxxxx/WEB-INF/beans.xml@7既不是注释@Interceptor也没有通过便携式扩展注册
我正在看CDI 1.1规范的1.3.6节,它看起来没什么变化,所以我做错了什么?
这是我正在使用的代码;
@InterceptorBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Secured {}
Run Code Online (Sandbox Code Playgroud)
@Secured
@Interceptor
public class SecuredInterceptor implements Serializable
{
@AroundInvoke
public Object interceptSecured(InvocationContext ic) throws Exception
{
// Do Stuff
}
}
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="annotated">
<interceptors>
<class>com.xxxxxx.security.SecuredInterceptor</class>
</interceptors>
</beans>
Run Code Online (Sandbox Code Playgroud) 我正在尝试运行connectorZ JCA 1.6 Executor实现,
为此我从github下载了Zip并尝试执行客户端,
(工作管理器:java.util.concurrent.Executor的JCA实现)
我能够在Eclipse中运行应用程序,(在解决了一些依赖性问题之后)
jsp页面正常加载链接"执行5个阻塞任务",
当我点击特定链接时,我得到以下异常:
Caused by: java.lang.NullPointerException
at org.connectorz.threading.ThreadsResource.overload(ThreadsResource.java:72) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_40]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_40]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_40]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_40]
Run Code Online (Sandbox Code Playgroud)
这里的问题是executorFactory为null,我不确定jndi_name" jca/workmanager ".
@Resource(name="jca/workmanager")
WorkExecutorFactory executorFactory; //NPE at executorFactory(not injecting).
Run Code Online (Sandbox Code Playgroud)
我是否缺少与jndi或任何资源文件相关的任何配置?
我该如何解决这个问题?
我正在尝试运行一个测试类,并面临与arquillian相关的一些问题.这是我得到的例外.
java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:160)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:111)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:97)
at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:93)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
Run Code Online (Sandbox Code Playgroud)
这是我的pom档案:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>Module</artifactId>
<groupId>foo.companey</groupId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>foo-core</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<classifier>cdi1.0</classifier>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId> …Run Code Online (Sandbox Code Playgroud) 是什么区别Futures.addCallBack(),并Futures.transform()在谷歌番石榴并发.
根据文件:
Futures.addCallBack():
addCallback(ListenableFuture<V> future, FutureCallback<? super V> callback)在Future的计算完成时,或者如果计算已经完成,立即注册单独的成功和失败回调.
Futures.transform():
transform(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function)返回一个新的ListenableFuture,其结果是从给定Future的结果异步派生的.
根据我的理解,addCallback()将在异步处理完成时注册成功或失败回调.在这种情况下,我们可以根据成功或失败条件处理输出(例如:日志记录,流量控制等.).并且transform()只返回异步对象.那么差异只是Callback?
AsyncFunction和Functionin有transform(ListenableFuture<I> input, Function/AsyncFunction <? super I,? extends O> function)什么区别?(AsyncFunction仅用于嵌套Futures.transform()?)我尝试了什么:
我尝试编写如下代码,这是否是一个好习惯.
public ListenableFuture<MyObject> doSomething() {
logger.info( "Entered in dosomething() Method." );
ListeningExecutorService executor =
MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(50));
ListenableFuture<MyObject> myAsyncObject =
calculator.calculateSomething(input);
//internally calculator.calculateSomething() have multiple asynchronous
// calls …Run Code Online (Sandbox Code Playgroud) 有没有人创建过一个在java中公开facebook messenger bot API的开源项目?(或我可以转换的另一种语言?)
基本上是堆栈的对象层次结构:https: //developers.facebook.com/docs/messenger-platform/send-api-reference
我宁愿不仅使用JsonObjects等,也不使用Maps来提取传入的JSON聊天消息或构建传出的结构化聊天回复.如果存在这样的开源项目 - 我还没有找到它.
我有一个String如下数组:
String[] titles = new String[] { "Booking", "Entry", "Type",
"Duration", "Status", "Contract ID",
"Capacity", "Start Day", "End Day", "Source Ref" };
Run Code Online (Sandbox Code Playgroud)
我需要在以后的状态下向这个数组附加一些值,如下所示:
titles = new String[] { "Booking", "Shipper", "Booking Quantity", "Entry",
"Type", "Duration", "Status",
"Contract ID", "Capacity", "Start Day",
"End Day", "Source Ref" };
Run Code Online (Sandbox Code Playgroud)
在这里我添加"Shipper", "Booking Quantity"到第一个数组.
有没有办法基于索引或任何方式附加这些值,而不创建像上面的例子?(可能吗?)
一些Log4j配置器有一个configureAndWatch()方法,它启动一个线程来观察用于配置的文件(XML文件或properties文件),并在文件发生变化时触发重新配置.
但是,如果您依赖于Log4j 默认初始化过程,则永远不会有机会调用configureAndWatch().您甚至不知道用于配置的文件(它甚至可能不是文件.)
是否有一种获得configureAndWatch()样式行为的好方法,允许动态更改日志配置,同时仍使用默认初始化过程?我假设你的配置URL最终解析为一个可以观看的文件,因为另一台服务器上的URL可能不是你想要每60秒拉一次的东西.
(我发现这个configureAndWatch()方法在Java EE 环境中是不安全的,因为单独的线程,我看到一些应用程序服务器有自己的机制来查看log4j配置文件,但我正在处理的程序目前没有运行在Java EE中.)
我有一个Main类和VOCollection类.在主类中有一个名为getStatus()的方法,从这个方法只有我得到一些状态(true,false),如果状态为true,我需要返回一个集合.目前我有两个想法,但两者都很昂贵.
返回映射,它很昂贵,因为为集合设置布尔会使代码混淆,只有一个布尔值就足够了(但我们返回多个).
在VOCollection类中创建实例变量,并使用getter和setter来获取和设置布尔值.这也很贵.(在另一个类中创建变量).
给我更便宜的解决方案.
以下代码返回错误说: "constructor call must be the first statment in a constructor."
我不懂.我的代码中的构造函数是第一个语句.我究竟做错了什么?
public class labelsAndIcons extends JFrame
{
public labelFrame()
{
super( "Testing JLabel" );
}
}
Run Code Online (Sandbox Code Playgroud) 由于触发了" "任务,有时事务日志文件可能会增长到数据大小的4倍.有什么建议的设置来避免这种情况?re-indexingSDL
我在嘲笑一个抛出的接口数组 java.lang.IllegalArgumentException: Cannot subclass final class class.
以下是我所做的更改。
按照完全相同的顺序在类级别添加了以下注释:
@Runwith(PowerMockRunner.class)
@PrepareForTest({ Array1[].class, Array2[].class })
Run Code Online (Sandbox Code Playgroud)
在课堂上,我这样做:
Array1[] test1= PowerMockito.mock(Array1[].class);
Array2[] test2= PowerMockito.mock(Array2[].class);
Run Code Online (Sandbox Code Playgroud)
和内部测试方法:
Mockito.when(staticclass.somemethod()).thenReturn(test1);
Mockito.when(staticclass.somediffmethod()).thenReturn(test2);
Run Code Online (Sandbox Code Playgroud)
基本上,我需要模拟一组接口。任何帮助,将不胜感激。
java ×7
append ×1
arrays ×1
asynchronous ×1
boolean ×1
bots ×1
cdi ×1
concurrency ×1
connector ×1
constructor ×1
database ×1
duplicates ×1
facebook ×1
frameworks ×1
glassfish ×1
guava ×1
interceptor ×1
java-ee-7 ×1
jboss6.x ×1
jca ×1
log4j ×1
logging ×1
messenger ×1
methods ×1
mockito ×1
oracle ×1
plsql ×1
powermock ×1
powermockito ×1
return ×1
rows ×1
servlet-3.0 ×1
string ×1
tridion ×1
tridion-2011 ×1
tridion2009 ×1