Jump to content

Recommended Posts

Posted

[quote name='Nawab__' timestamp='1355494189' post='1302950514']


em aindhi idly, poddhun poddhunna poonakam vacchinatlu maatladuthunnav :D
[/quote]

Lekapothe endi nice african joke, American joke , cambodia joke, kakara kaya joke anukunta

  • Replies 48
  • Created
  • Last Reply

Top Posters In This Topic

  • chinni005

    22

  • Nawab__

    8

  • Idly Vishwanatham

    7

  • manmadudhu

    4

Popular Days

Top Posters In This Topic

Posted

[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 :D

Posted

[quote name='Idly Vishwanatham' timestamp='1355494136' post='1302950511']
Needi, nawab ganivi matram nice kullu jokes
[/quote]
guss avthav endhi miyaav :D filli lekka :P

Posted

[quote name='Hava5' timestamp='1355494288' post='1302950520']

ninu sampestha twaralo :D
[/quote]

Contact me anytime if u need my helping hands for this task

Posted

[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 :D kakara kaya joke aithey, marvelous CITI_c$y

Posted

[quote name='manmadudhu' timestamp='1355494340' post='1302950523']
gm
[/quote]
congrats re junnu :D

Posted

[quote name='Idly Vishwanatham' timestamp='1355494350' post='1302950525']
Contact me anytime if u need my helping hands for this task
[/quote]
:D baaga kakscha undhi neeku

Posted

[quote name='Hava5' timestamp='1355494379' post='1302950529']
congrats re junnu :D
[/quote]
adenti gm sefthe congrats antunav[img]http://www.andhrafriends.com/uploads/gallery/album_15/gallery_24383_15_756.gif[/img]

Posted

[quote name='manmadudhu' timestamp='1355494448' post='1302950531']
adenti gm sefthe congrats antunav
[/quote]
:D monna theddu soosale voo.. endhi katha :D

Posted

[quote name='Hava5' timestamp='1355494479' post='1302950533']
:D monna theddu soosale voo.. endhi katha :D
[/quote]
ohhh work permit theddaaa :D tq tq :)

Posted

[quote name='manmadudhu' timestamp='1355494520' post='1302950534']
ohhh work permit theddaaa :D tq tq :)
[/quote]
neeku idly lekka samber ekkuva chuntney thakkuva ayindhi e madhya :P

Posted

[quote name='Hava5' timestamp='1355494595' post='1302950539']
neeku idly lekka samber ekkuva chuntney thakkuva ayindhi e madhya :P
[/quote]
nee degara ki vachetha full chutney aa ga inka :D

Posted

@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]

Posted

[quote name='manmadudhu' timestamp='1355494718' post='1302950543']
nee degara ki vachetha full chutney aa ga inka :D
[/quote]
:P lol

×
×
  • Create New...