81,116
社区成员
发帖
与我相关
我的任务
分享
i18n (数字1) 写成了 il8n (字母l)
还有一次是
DriverManager.getConnection( " jdbc:sqlserver://localhost;databaseName=school", "usr", "pass");
// 注意前面的空格
这两个错误都让我废了好长时间才找到, lz不妨看看是不是哪个细节写错了, 比如用户名, 密码什么的...
祝好运...


public ConnectionManager(String url, String password, String user) {
这个是password,user。 但是在传参的时候是user,password传的。so,你懂得。让后我一直能用的那个账户,正好是
user = password 的。我也是该给自己深深的鞠上一躬了。
public ConnectionManager(String url, String password, String user) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
System.out.println("driver added error.");
e.printStackTrace();
}
this.url = url;
this.password = password;
this.user = user;
}
private Connection connection=null;
public Utils() {
connection = ConnectionFactory.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xe", "mayufeng", "mayufeng");
}
package com.tyut.beans;
import java.sql.Connection;
public class ConnectionFactory {
private static ConnectionManager connectionManager;
public static Connection getConnection(String url, String username,
String paswword) {
if (connectionManager == null) {
connectionManager = new ConnectionManager(url, username, paswword);
}
return connectionManager.getConnection();
}
}
public ConnectionManager(String url, String password, String user) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
System.out.println("driver added error.");
e.printStackTrace();
}
this.url = url;
this.password = password;
this.user = user;
}
package com.tyut.listener;
import java.util.Date;
import java.util.Timer;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import com.tyut.service.Wages;
/**
* Application Lifecycle Listener implementation class SetAllPay
*
*/
public class SetAllPay implements ServletContextListener {
private Timer timer = null;
/**
* Default constructor.
*/
public SetAllPay() {
// TODO Auto-generated constructor stub
}
/**
* @see ServletContextListener#contextInitialized(ServletContextEvent)
*/
public void contextInitialized(ServletContextEvent arg0) {
// TODO Auto-generated method stub
timer = new Timer(true);
Date date = new Date();
date.setYear(115);
date.setMonth(3);
date.setDate(14);
date.setMinutes(48);
// timer.schedule(new Wages(), date, 1000*60*2);
long d =1000*60*60*24*30L;
timer.schedule(new Wages(), date, d);
}
/**
* @see ServletContextListener#contextDestroyed(ServletContextEvent)
*/
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
timer.cancel();
}
}
package com.tyut.service;
import java.util.TimerTask;
import com.tyut.dao.Utils;
public class Wages extends TimerTask{
@Override
public void run() {
// TODO Auto-generated method stub
Utils utils = new Utils();
utils.setAllPay();
}
}
<listener>
<listener-class>com.tyut.listener.SetAllPay</listener-class>
</listener>
创建用户的时候就给分配的。