问题描述
packagecom.fxz.dao;importjava.io.File;importjava.io.FileInputStream;importjava.io.FileNotFoundException;importjava.io.IOException;importjava.sql.Connection;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjava.util.Properties;importjavax.sql.DataSource;importorg.apache.commons.dbcp.BasicDataSourceFactory;publicclassDBManager{privatestaticDataSourceds;static{Filefile=newFile("dbconfing.properties");FileInputStreamfin=null;try{fin=newFileInputStream(file);}catch(FileNotFoundExceptione1){e1.printStackTrace();}Propertiespro=newProperties();try{pro.load(fin);}catch(IOExceptione){e.printStackTrace();}try{ds=BasicDataSourceFactory.createDataSource(pro);}catch(Exceptione){e.printStackTrace();}}publicstaticConnectiongetCon()throwsSQLException{returnds.getConnection();}publicstaticvoidcloseAll(Connectionconn,Statementste,ResultSetrs){if(rs!=null){try{rs.close();}catch(SQLExceptione){e.printStackTrace();}}if(ste!=null){try{ste.close();}catch(SQLExceptione){e.printStackTrace();}}if(conn!=null){try{conn.close();}catch(SQLExceptione){e.printStackTrace();}}}}代码如上,我用的是eclipse,sqlsever2008建立了数据库parking不知道怎么连接啊