
i have one table in database, now i want to store in notepad these table field, how is it possible through jdbc?

Hi Friend,
Try the following code:
import java.io.*;
import java.sql.*;
import java.util.*;
class InsertToFile {
private static void writeToFile(java.util.List<String> list, String path) {
BufferedWriter out = null;
try {
File file = new File(path);
out = new BufferedWriter(new FileWriter(file, true));
for (String s : list) {
out.write(s);
out.newLine();
}
out.close();
} catch (IOException e) {
}
}
public static void main(String arg[]) {
java.util.List<String> list = new ArrayList<String>();
try {
Connection con = null;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/register", "root", "root");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("Select * from student");
while (rs.next()) {
list.add(rs.getString(1) + " " + rs.getString(2) + " "+ rs.getString(3) + " " + rs.getString(4));
}
writeToFile(list, "student.txt");
} catch (Exception e) {
}
}
}
Thanks

I getting this type error
Exception in thread "main" java.lang.NoClassDefFoundError:InsertToFile
tanks you sir

Hi Friend,
It seems that you have saved the file with another name. Check your code whether the class name defined in the code and name through which the file is saved, are same?
Thanks