package com.trs.web2frame.myutils;

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

import com.trs.web2frame.tool.tyjyh.ConnectionUtil;
import com.trs.web2frame.tool.tyjyh.ConnectionUtil2;

public class WriteChannelvwcm {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		int pid=0;
		writeChildrenContentRoot(pid, 0);
	}
	
	private static void writeChildrenContent(int parentid, int level) throws Exception {
//		StringBuilder sb = new StringBuilder("select * from PE_Nodes where parentid='" + parentid+"' order by OrderID");
		StringBuilder sb = new StringBuilder("select * from wcmchannel where parentid='" + parentid+"' order by chnlorder");
		Connection connection = ConnectionUtil2.getConnection();
		Statement st = connection.createStatement();
		ResultSet rs = st.executeQuery(sb.toString());
		
		while (rs.next()) {
			for (int i=0; i<level; i++) {
				//System.out.print("\t");
			}
			System.out.println(rs.getString("chnldesc")+"	"+rs.getString("channelid"));
		//	if (rs.getInt(null)i)
			writeChildrenContent(rs.getInt("channelid"), level+1);
		}
		
		ConnectionUtil.closeConnection(rs, st, connection);
	}
	
	
	
	private static void writeChildrenContentRoot(int parentid, int level) throws Exception {
		System.out.print("\t");
		System.out.println(11777);
		writeChildrenContent(11777, level+1);
	}

}
