我有一个包含日期的数据库表
(`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00').
Run Code Online (Sandbox Code Playgroud)
我正在使用MySQL.从程序中,有时数据会在没有日期的情况下传递到数据库.因此,日期值被自动分配给0000-00-00 00:00:00
调用表数据时,它会给出错误的日期列
...'0000-00-00 00:00:00' can not be represented as java.sql.Timestamp.......
Run Code Online (Sandbox Code Playgroud)
我尝试将空值传递给插入数据的日期,但它会分配给当前时间.
有没有什么方法可以在ResultSet不改变表结构的情况下得到它?
我是 mapstruct 的新手。我正在尝试映射ItemInfo到Item对象,以下是我的类。
public class ItemInfo {
private String itemOwner;
private String itemOwnerArea;
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
以下是我打算转换为的课程
public class Item {
private UserInfo owner;
// getters and setters.
}
Run Code Online (Sandbox Code Playgroud)
UserInfo 类(注意它有两个构造函数)
public class UserInfo {
private final String username;
private final String area;
public UserInfo(String username, String area){
//set
}
public UserInfo(String info) {
//set
}
// getters only
}
Run Code Online (Sandbox Code Playgroud)
我已经创建了如下的映射器界面
@Mapper
public interface ItemMapper {
ItemMapper INSTANCE = Mappers.getMapper(ItemMapper.class);
@Mapping(source = "itemOwner", target = …Run Code Online (Sandbox Code Playgroud) 我是nodejs编程的新手.所以请耐心等待我.
我有两个nodejs模块.一次传递将消息传递给另一个nodejs模块.第二个处理它并将结果传递回第一个模块.
方法1
第一个模块
:
secondModule.callFunction(message, function(data){
//deal with the return message from the second module
})
:
Run Code Online (Sandbox Code Playgroud)
第二个模块
:
function callfunction(message, callback){
//asynchornous functions for processing
callback(data);
}
:
Run Code Online (Sandbox Code Playgroud)
方法2
同样的事情,但在第二个模块中使用事件发射器完成
第一个模块
:
secondModule.callFunction(message){
})
secondModule.on('done_event', function(data){
//deal with the reply
});
:
Run Code Online (Sandbox Code Playgroud)
第二个模块(使用事件发射器)
:
function callFunction(message){
//asynchornous functions for processing
self.emit('done_event', data);
}
:
Run Code Online (Sandbox Code Playgroud)
他们都是正确的.这些东西有什么不同(两者都是异步的)或者我做过一些愚蠢的事情.
提前致谢
我正在通过SSL连接到Web服务.我导入了证书并将其添加到java密钥库中.然后我使用wsdl2java为Web服务创建了客户端存根.
当我在程序中使用它并尝试调用服务时,它会抛出follownig(异常的一部分)
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.neethi.Constants.isPolicyElement(Ljavax/xml/namespace/QName;)Z
at org.apache.axis2.util.PolicyUtil.getPolicyChildren(PolicyUtil.java:287)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:157)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:857)
.
.
.
Run Code Online (Sandbox Code Playgroud)
我的代码有点像这样
public static void main(String[] args) {
//generated by wsdl2java
Clientstub stub = new ClientStub(endpoint);
.
.
//req is the passed parameter
stub.requestServic(req);
Run Code Online (Sandbox Code Playgroud)
}
我想我必须导入一些安全策略.如果有的话可以帮助我(任何教程或指示).
提前致谢
我试图从流中获取内容的副本而不使用它。我的计划是在后面的代码中使用这个原始流。以下是我尝试检查的示例代码。我的目的是保留原始的InputStream以供将来在获得副本后使用
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
public class StreamTest {
public static void main(String[] args) {
try {
InputStream inputstream = new FileInputStream("resource.txt"); // content of the file is 'test'
ByteArrayOutputStream baos = new ByteArrayOutputStream();
org.apache.commons.io.IOUtils.copy(inputstream, baos);
byte[] bytes = baos.toByteArray();
System.out.println("copied stream : " + new String(bytes));
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(inputstream));
String line;
while ((line = br.readLine()) != null) {
sb.append(line + System.lineSeparator());
}
System.out.println("original stream : …Run Code Online (Sandbox Code Playgroud) java ×4
asynchronous ×1
javascript ×1
jdbc ×1
mapstruct ×1
mysql ×1
node.js ×1
timestamp ×1
web-services ×1
wsdl2java ×1