日期:2014-05-16 浏览次数:20436 次
import java.io.FileNotFoundException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Map; import javax.xml.bind.JAXBException; public class QueryBtwRecharge { public void query() throws FileNotFoundException, JAXBException, ClassNotFoundException, SQLException{ ConnConfReader connConfReader=new ConnConfReader(); Map<String,String> map=connConfReader.getConnConf(); String dbDriver=map.get("dbDriver"); String url=map.get("url"); String user=map.get("user"); String password=map.get("password"); String sql=map.get("sql"); Class.forName(dbDriver); Connection conn=DriverManager.getConnection(url, user, password); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery(sql); while(rs.next()){ // System.out.println(rs.getString("cardnum")+"\t"+ // rs.getString("total_fee")+"\t"+ // rs.getString("createdate")+"\t"+ // rs.getString("ip")+"\t"+ // rs.getString("buyer_email")+"\t" // ); System.out.println(rs.getString(1)+"\t"+ rs.getString(2)+"\t"+ rs.getString(3)+"\t"+ rs.getString(4)+"\t" ); } if(rs!=null){rs.close();} if(stmt!=null){stmt.close();} if(conn!=null){conn.close();} } }