Idly Vishwanatham Posted December 14, 2012 Report Posted December 14, 2012 [quote name='Nawab__' timestamp='1355494189' post='1302950514'] em aindhi idly, poddhun poddhunna poonakam vacchinatlu maatladuthunnav [/quote] Lekapothe endi nice african joke, American joke , cambodia joke, kakara kaya joke anukunta
chinni005 Posted December 14, 2012 Author Report Posted December 14, 2012 [quote name='Nawab__' timestamp='1355494139' post='1302950512'] ah display pic needhey ani naak ndhuku cheppaledhu [img]http://lh6.ggpht.com/_ahdVBRNtM48/TENCVzQL1hI/AAAAAAAAAb0/ky7VHIvQ34w/s400/gamessi3.png[/img] [/quote] ninu sampestha twaralo
chinni005 Posted December 14, 2012 Author Report Posted December 14, 2012 [quote name='Idly Vishwanatham' timestamp='1355494136' post='1302950511'] Needi, nawab ganivi matram nice kullu jokes [/quote] guss avthav endhi miyaav filli lekka
Idly Vishwanatham Posted December 14, 2012 Report Posted December 14, 2012 [quote name='Hava5' timestamp='1355494288' post='1302950520'] ninu sampestha twaralo [/quote] Contact me anytime if u need my helping hands for this task
Nawab__ Posted December 14, 2012 Report Posted December 14, 2012 [quote name='Idly Vishwanatham' timestamp='1355494283' post='1302950519'] Lekapothe endi nice african joke, American joke , cambodia joke, kakara kaya joke anukunta [/quote] nice timing needhi kakara kaya joke aithey, marvelous
chinni005 Posted December 14, 2012 Author Report Posted December 14, 2012 [quote name='manmadudhu' timestamp='1355494340' post='1302950523'] gm [/quote] congrats re junnu
chinni005 Posted December 14, 2012 Author Report Posted December 14, 2012 [quote name='Idly Vishwanatham' timestamp='1355494350' post='1302950525'] Contact me anytime if u need my helping hands for this task [/quote] baaga kakscha undhi neeku
manmadudhu Posted December 14, 2012 Report Posted December 14, 2012 [quote name='Hava5' timestamp='1355494379' post='1302950529'] congrats re junnu [/quote] adenti gm sefthe congrats antunav[img]http://www.andhrafriends.com/uploads/gallery/album_15/gallery_24383_15_756.gif[/img]
chinni005 Posted December 14, 2012 Author Report Posted December 14, 2012 [quote name='manmadudhu' timestamp='1355494448' post='1302950531'] adenti gm sefthe congrats antunav [/quote] monna theddu soosale voo.. endhi katha
manmadudhu Posted December 14, 2012 Report Posted December 14, 2012 [quote name='Hava5' timestamp='1355494479' post='1302950533'] monna theddu soosale voo.. endhi katha [/quote] ohhh work permit theddaaa tq tq
chinni005 Posted December 14, 2012 Author Report Posted December 14, 2012 [quote name='manmadudhu' timestamp='1355494520' post='1302950534'] ohhh work permit theddaaa tq tq [/quote] neeku idly lekka samber ekkuva chuntney thakkuva ayindhi e madhya
manmadudhu Posted December 14, 2012 Report Posted December 14, 2012 [quote name='Hava5' timestamp='1355494595' post='1302950539'] neeku idly lekka samber ekkuva chuntney thakkuva ayindhi e madhya [/quote] nee degara ki vachetha full chutney aa ga inka
chinni005 Posted December 14, 2012 Author Report Posted December 14, 2012 @fake idhi try chy [CODE] package com.xbrl.dao; import java.io.FileWriter; import java.io.IOException; import java.sql.*; import java.util.ArrayList; import java.util.List; import jxl.write.Label; import com.utility.HibernateUtil; public class DB2CSV { /** * @param args */ public static void main(String[] args) { //usual database connection part Connection con = null; String url = "jdbc:mysql://localhost:3306/"; String db = "db_name"; String driver = "com.mysql.jdbc.Driver"; String user = "username"; String pass = "password"; FileWriter fw ; try{ Class.forName(driver); con = DriverManager.getConnection(url+db, user, pass); Statement st = con.createStatement(); //this query gets all the tables in your database(put your db name in the query) ResultSet res = st.executeQuery("SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'db_name' "); //Preparing List of table Names List <String> tableNameList = new ArrayList<String>(); while(res.next()) { tableNameList.add(res.getString(1)); } //path to the folder where you will save your csv files String filename = "D:/db2csv/"; //star iterating on each table to fetch its data and save in a .csv file for(String tableName:tableNameList) { int k=0; int j=1; System.out.println(tableName); List<String> columnsNameList = new ArrayList<String>(); //select all data from table res = st.executeQuery("select * from xcms."+tableName); //colunm count is necessay as the tables are dynamic and we need to figure out the numbers of columns int colunmCount = getColumnCount(res); try { fw = new FileWriter(filename+""+tableName+".csv"); //this loop is used to add column names at the top of file , if you do not need it just comment this loop for(int i=1 ; i<= colunmCount ;i++) { fw.append(res.getMetaData().getColumnName(i)); fw.append(","); } fw.append(System.getProperty("line.separator")); while(res.next()) { for(int i=1;i<=colunmCount;i++) { //you can update it here by using the column type but i am fine with the data so just converting //everything to string first and then saving if(res.getObject(i)!=null) { String data= res.getObject(i).toString(); fw.append(data) ; fw.append(","); } else { String data= "null"; fw.append(data) ; fw.append(","); } } //new line entered after each row fw.append(System.getProperty("line.separator")); } fw.flush(); fw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } con.close(); } catch (ClassNotFoundException e){ System.err.println("Could not load JDBC driver"); e.printStackTrace(); } catch(SQLException ex){ System.err.println("SQLException information"); } } //to get numbers of rows in a result set public static int getRowCount(ResultSet res) throws SQLException { res.last(); int numberOfRows = res.getRow(); res.beforeFirst(); return numberOfRows; } //to get no of columns in result set public static int getColumnCount(ResultSet res) throws SQLException { return res.getMetaData().getColumnCount(); } } [/CODE]
chinni005 Posted December 14, 2012 Author Report Posted December 14, 2012 [quote name='manmadudhu' timestamp='1355494718' post='1302950543'] nee degara ki vachetha full chutney aa ga inka [/quote] lol
Recommended Posts