Exportieren von oracle-Datenbank in eine csv-Datei

import java.io.*;
import java.sql.*;
public class CsvF {

public static void main(String[] args) {
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection conn= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","sandp");
conn.setAutoCommit(false);
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from tet where to_char(S_DATE,'HH24') = '23'");

ResultSetMetaData rsmd = rs.getMetaData();
FileWriter cname = new FileWriter("D:\\asd.csv");
BufferedWriter bwOutFile = new BufferedWriter(cname);
StringBuffer sbOutput = new StringBuffer();
sbOutput.append("S_DATE");
bwOutFile.append(sbOutput);
bwOutFile.append(System.getProperty("line.separator"));
System.out.println("No of columns in the table:"+ rsmd.getColumnCount());

for (int i = 1; i <= rsmd.getColumnCount(); i++) 
{
String  fname = rsmd.getColumnName(i);
}

System.out.println();



while(rs.next())
{
System.out.print(rs.getString(1));
bwOutFile.append(rs.getString(1));
bwOutFile.append(System.getProperty("line.separator"));
bwOutFile.flush();
System.out.println();
} 
conn.close();

}
catch(SQLException se)
{
se.printStackTrace();
}
catch(Exception e)
    {
System.out.println("Unable to connect to database" +e);
}

}


}

hier bin ich, um Daten in asd.csv-Datei wie folgt=
2015-2-26.23.21. 0. 0

2015-2-26.23.43. 0. 0

2015-2-27.23.28. 0. 0

2015-2-27.23.50. 0. 0

2015-3-1.23.19. 0. 0

2015-3-1.23.41. 0. 0

aber ich will Daten folgende format =
2015-02-26 23:21

2015-02-26 23:43

2015-02-27 23:28

2015-02-27 23:50

2015-03-01 23:19

2015-03-01 23:41

bin ich immer ein extra-Punkt(".") in der Ausgabe... was mache ich falsch?
ich habe eine Tabelle erstellen namens tet mit Spalte(S_DATE), wo S_DATE ist timestamp...kann mir jemand helfen?

InformationsquelleAutor ARoy | 2015-05-07
Schreibe einen Kommentar