package jsp;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class csvp {
	private String username;
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}



	public String x;
	
	public csvp(){
		
		
	}
	
	
	
	
	public String receive(){
		
		try {Context initCtx = new javax.naming.InitialContext(); 
		Context envCtx = (Context) initCtx.lookup("java:comp/env"); 
		DataSource ds;
			ds = (DataSource)envCtx.lookup("jdbc/mysql");
		
		try {Connection con =  ds.getConnection();
		Statement stmt;
			stmt = con.createStatement();
		String sql="Select * from user" ;
		System.out.println(sql);
		ResultSet rs= stmt.executeQuery(sql);
		
		
		x="";
		if (!rs.next()){x="���޴���";}else{
			rs.beforeFirst();
	while (rs.next()){
	
		//x+=rs.getString(2);
		
		 		x+= rs.getRow()+",";
		 		x+=rs.getString(2)+",";
		 				x+=rs.getString(3)+"\n";
		 						
	}
		}
	
		rs.close();
		stmt.close();
		con.close();
		} catch (SQLException e) {
			// TODO �Զ���ɵ� catch ��
			e.printStackTrace();
		}
		} catch (NamingException e) {
			// TODO �Զ���ɵ� catch ��
			e.printStackTrace();
		} ;
		System.out.println(x);
		return x.trim();
		
		
		}
}
最近下载更多
qiuqiuqiu111  LV4 2022年11月29日
yymmyy  LV1 2021年10月28日
ewofl888  LV1 2021年6月21日
2539788229  LV4 2021年1月4日
ahly88  LV1 2020年11月7日
jiayouyy  LV8 2020年6月1日
柠檬味汽水  LV1 2020年4月13日
3478CH  LV9 2019年11月21日
2308478564  LV15 2019年11月18日
1219610676  LV4 2019年9月28日
最近浏览更多
WHY-small  LV15 2023年12月29日
lanana  LV1 2023年12月22日
321170193  LV6 2023年11月12日
sdfgsdfg  LV2 2023年10月23日
monolog  LV4 2023年5月11日
月光skr  LV3 2023年4月9日
小逸夜  LV4 2022年12月27日
qiuqiuqiu111  LV4 2022年11月29日
chengchengya  LV2 2022年10月2日
13112360  LV2 2022年9月27日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友