db.properties
//由于工作原因我把真实服务器给隐藏了
db.url="jdbc:sqlserver://1.1.1.1:1433;databaseName=test"
db.username=******
db.password=******
db.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
db.validationQuery=select 1
db.maxActive=100
dao.js
var ioc = {
conf : {
type : "org.nutz.ioc.impl.PropertiesProxy",
fields : {
paths : ["custom/"]
}
},
dataSource : {
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
create : "init",
depose : 'close'
},
fields : {
url : {java:"$conf.get('db.url')"},
username : {java:"$conf.get('db.username')"},
password : {java:"$conf.get('db.password')"},
driverClassName : {java:"$conf.get('db.driverClassName')"},
testWhileIdle : true,
validationQuery : {java:"$conf.get('db.validationQuery')"},
maxActive : {java:"$conf.get('db.maxActive')"},
//druid监控
filters : "mergeStat",
connectionProperties : "druid.stat.slowSqlMillis=2000"
}
},
dao : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource"}]
}
};
报错提示
java.sql.SQLException: connect error, url "jdbc:sqlserver://1.1.1.1;databaseName=test", driverClass com.microsoft.sqlserver.jdbc.SQLServerDriver
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1481)
at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1998)