标签:
创建configuration时,发现URLParser找不到,于是只能使用配置文件来,当然使用配置文件比使用URL初始化还要直观些
def configurationWithPassword = new Configuration( host = "localhost", port = 3306, username = "root", password = Some("123"), database = Some("test") )
Configuration文件本身是case class,它的code是
case class Configuration(username: String, host: String = "localhost", port: Int = 5432, password: Option[String] = None, database: Option[String] = None, charset: Charset = Configuration.DefaultCharset, maximumMessageSize: Int = 16777216, allocator: AbstractByteBufAllocator = PooledByteBufAllocator.DEFAULT, connectTimeout: Duration = 5.seconds, testTimeout: Duration = 5.seconds )
这让我想到了slick,slick我连配置文件都搞不出来。总觉得slick的设计有些反人类。
对于单连接
def sinConnection: MySQLConnection = { val configuration: Configuration = configurationWithPassword new MySQLConnection(configuration) }
对于线程池连接
def poolConnection: ConnectionPool[MySQLConnection] = { val configuration: Configuration = configurationPool val factory = new MySQLConnectionFactory(configuration) val pool = new ConnectionPool[MySQLConnection](factory, PoolConfiguration.Default) pool }
ResultSet并不是java.sql.resultSet而是作者自己创建的新类型
trait ResultSet extends IndexSeq[RowData]
而rowData则表示一行数据,也是一个顺序表
trait RowData extends IndexedSeq[Any]
这样,ResultSet就像是个二维表了
标签:
原文地址:http://www.cnblogs.com/xinsheng/p/4336066.html