에러 java.sql.Timestamp cannot be cast to java.lang.String
DB에 timestamp 타입의 열을 만들면 자바에서 위의 에러를 뱉어낼 때가 있다.
이럴때는 쿼리문 또는 자바에서 데이트포맷을 변경해주어야 한다.
예를 들어 xml파일에 아래의 쿼리문을 입력하면
SELECT MEMBER_ID, MEMBER_PASS, LOGIN_DATE
FROM MEMBER
LOGIN_DATE의 데이터타입이 timestamp라면 java.sql.Timestamp cannot be cast to java.lang.String 에러를 띄우게 되는데 그때는 아래의 쿼리문으로 바꾸면 된다.
SELECT MEMBER_ID, MEMBER_PASS,
DATE_FORMAT(LOGIN_DATE, '%Y-%m-%d %H:%i:%s') AS LOGIN_DATE
FROM MEMBER
march, june같은 영어 월로 바꾸려면 %m을 %M으로 바꾸면된다.
또한 2020-07-08 08:20:05 <<이런 데이터를 15914634~~같은 UNIX타입으로 변화시키려면 아래 자바코드를 이용한다.
import java.util.Date
//String으로 되어 있는 날짜를 UNIX타입으로 저장
java.sql.Timestamp date_timestamp01 = java.sql.Timestamp.valueOf(date_string);
long date_timestamp02 = date_timestamp01.getTime(); //date_timestamp02의 값은 159823~~~값을 가진다.
//현재 시간을 UNIX타입 으로 저장하는 코드
Long now01 = System.currentTimeMillis();
//현재 시간을 yyyy-MM-dd HH:mm:ss 포맷으로 저장하는 코드
Date now = new Date(); //Date타입으로 변수 선언
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //데이트 포맷
String date_string = dateFormat.format(now); //날짜가 string으로 저장
개인적으로 --no-warp를 적어주는 것이 좋다. 아니면 아래처럼 스냅샷찍다가 멈춰버리는 경우가 잦다.
노드서버의 아이피와 포트는172.16.0.131:30301로 둔다.
그리고 슬레이브 서버 아이피는 10.26.10.118로 둔다.
1. TOML파일 설정
basepath 안에 eth-config.toml 파일에 아래와 같이 값을 입력한다.
author를 공란으로 두면 에러가 뜨므로 자신의 아이피를 적는다.
# 뒤에 것들은 적용되지 않는 코드이므로 무시해도 된다.
eth-config.toml
# This config should be placed in following path:
# %UserProfile%\AppData\Roaming\Parity\Ethereum\config.toml
[parity]
# Local Development Chain
#chain = "mainnet"
# Blockchain and settings will be stored in D:\blocks/Parity\Ethereum.
#base_path = "D:\\blocks/Parity\\Ethereum"
# Parity databases will be stored in D:\blocks\Parity\Ethereum\chains.
#db_path = "D:\\blocks\\Parity\\Ethereum\\chains"
#[ui]
# Wallet will be accessible on port 8181.
#port = 8180
[account]
# From: [conco,test] you'll be able to send tranasactions without password.
#unlock = [0x6E27B320EdAae409438BDB05AC636f51fc920BA4, " "]
[network]
# Parity will listen for connections on port 30301.
#reserved_only = true
#reserved_peers = "./myPrivateNetwork.txt"
port = 30301
[rpc]
port = 10110
interface = "0.0.0.0"
hosts = ["all"]
apis = ["web3", "eth", "net", "parity", "traces", "rpc", "parity_accounts","personal"]
[websockets]
# UI won't work and WebSockets server will be not available.
#웹소켓을 안쓰니 안적어도 무방
port = 11010
#disable = true
[ipc]
# You won't be able to use IPC to interact with Parity.
#disable = true
#path = "D:\\blocks\\Parity\\Ethereum\\chains\\jsonrpc.ipc"
# Only selected APIs will be exposed over this interface.
#apis = ["web3", "eth", "net", "parity", "parity_accounts", "traces", "rpc"]
#[footprint]
# Increase performance on HDD.
#db_compaction = "hdd"
[mining]
#아래 지갑주소는 본인의 주소로 입력한다.
author = "0x00e3F02bb8aaE3927Fcd4fa89caD35730aEE0E58"
[misc]
#log_file = "C:\\ETHLOG\\Ethereum.log"
위를 요약하면 노드의 30301포트 네트워크로 접속하여 10110포트로 쏴준다는 뜻이다.
따라서 지갑에 접속할 때 10.26.10.118 Host의 10110 port로 접속하면 된다.
2. enode 설정
노드에 연결을 하려면 enode 값이 필요하다.
노드서버를 실행시키면 나오는 enode값을 저장해두고 basepath에 txt 문서를 하나 만들어 enode값을 입력한다.