package dater;

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

import javax.annotation.Resource;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ManagedConnection;

import stations.Stations;

public class dater {

	public static String getStr(javax.sql.DataSource ds00)
	{
		String res="";
		Connection conn2 = null;
		try {
		
		//	ds00.
		if(null==ds00){res="null==ds00";return res;}
		if(null==ds00.getConnection()){res="null==ds00.getConnection()";return res;}
		
  	    conn2= ds00.getConnection();
        String sql="SELECT id as id,name as name from system.g000();";
  	    PreparedStatement ps = conn2.prepareStatement(sql);
  	    //ps.setInt(1, 0);
  	    ResultSet rs = ps.executeQuery();

  	    	while(rs.next())
  	    	{
  	    	System.out.println("rs.next()");
  	    	res+=rs.getString(rs.findColumn("name"))+",";
  	    	}
  	    	
  	    	ps.close();	 
  	    	if(null!=conn2)conn2.close();
  	    	System.out.println("conn2.isClosed()="+conn2.isClosed());
  	    	}
		 catch (SQLException e)
		 {
			System.out.println("error2="+e);
		 }
		finally{
			try {
				if(null!=conn2)conn2.close();
			    } catch (SQLException e) {
				e.printStackTrace();
			                             }
		}
		
		
		return res;
		
	}

}
