/*
* DesktopApplication1.java
*/
package desktopapplication1;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.*;
import java.sql.*;
import java.util.*;
/**
* The main class of the application.
*/
public class DesktopApplication1 extends SingleFrameApplication {
/**
* At startup create and show the main frame of the application.
*/
@Override protected void startup() {
show(new DesktopApplication1View(this));
}
/**
* This method is to initialize the specified window by injecting resources.
* Windows shown in our application come fully initialized from the GUI
* builder, so this additional configuration is not needed.
*/
@Override protected void configureWindow(java.awt.Window root) {
}
/**
* A convenient static getter for the application instance.
* @return the instance of DesktopApplication1
*/
public static DesktopApplication1 getApplication() {
return Application.getInstance(DesktopApplication1.class);
}
/**
* Main method launching the application.
*/
public static void main(String[] args) {
launch(DesktopApplication1.class, args);
FileWriter fw=null;
Connection con=null;
PreparedStatement pstm=null;
ResultSet result = null;
// String line = null;
try {
fw=new FileWriter("E:\\test\\testforjava\\out.txt");
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/testforjava","root","root");
pstm = con.prepareStatement("select * from whp");
result = pstm.executeQuery();
while(result.next()){
String id=result.getString(1);
String name=result.getString(2);
fw.write(id);
// fw.flush();
fw.write(name);
fw.write("\r\n");
}
}catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch(IOException e) {
}finally{
if(fw!=null)
try{
fw.close();
}catch(IOException e){
}
}
}
}