yichen
2 years ago
11 changed files with 120 additions and 37 deletions
@ -0,0 +1,57 @@
|
||||
package com.fanruan; |
||||
|
||||
import com.fanruan.cache.BeanCacheImpl; |
||||
import com.fanruan.handler.DispatcherImpl; |
||||
import com.fanruan.pojo.message.RpcRequest; |
||||
import com.fanruan.service.jdbc.AbstractBind; |
||||
import com.fanruan.service.jdbc.statement.ServiceStatement; |
||||
import org.junit.jupiter.api.Assertions; |
||||
import org.junit.jupiter.api.BeforeAll; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.junit.jupiter.api.TestInstance; |
||||
|
||||
import java.net.URL; |
||||
import java.sql.Connection; |
||||
import java.sql.ResultSet; |
||||
import java.sql.SQLException; |
||||
import java.sql.Statement; |
||||
|
||||
/** |
||||
* @author Yichen Dai |
||||
* @date 2022/9/7 10:58 |
||||
*/ |
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) |
||||
public class ResultSetTest extends BaseJDBCTest{ |
||||
|
||||
private Connection connection = null; |
||||
|
||||
@BeforeAll |
||||
public void setUp() throws SQLException { |
||||
openSocket(); |
||||
connection = getConnection(); |
||||
Statement statement = connection.createStatement(); |
||||
statement.execute("create table DemoTable\n" + |
||||
" (\n" + |
||||
" Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n" + |
||||
" TestTime TIME, \n" + |
||||
" TestDate DATE, \n" + |
||||
" TestStamp TIMESTAMP\n" + |
||||
" );"); |
||||
|
||||
statement.executeUpdate("insert into DEMOTABLE(TESTTIME,TESTDATE,TESTSTAMP) " + |
||||
"values('15:50:37', '2022-09-07', '2022-09-07 15:50:37');"); |
||||
} |
||||
|
||||
@Test |
||||
public void testDate() throws SQLException{ |
||||
Statement statement = connection.createStatement(); |
||||
ResultSet resultSet = statement.executeQuery("select TestTime, TestDate, TestStamp from DemoTable;"); |
||||
|
||||
while(resultSet.next()){ |
||||
Assertions.assertEquals("15:50:37", resultSet.getTime(1).toString()); |
||||
Assertions.assertEquals("2022-09-07", resultSet.getDate(2).toString()); |
||||
Assertions.assertEquals("2022-09-07 15:50:37.0", resultSet.getTimestamp(3).toString()); |
||||
} |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue