-1
URL에서 콘텐츠를 다운로드하고 데이터베이스에 삽입하려고합니다. 이미 다운로드했지만 텍스트 영역의 한 줄에 표시됩니다. 텍스트 영역에 (필요한 경우 줄 바꿈 된) 단락처럼 표시하고 싶습니다. 여기에 내가 시도 것입니다 :URL 저장소의 콘텐츠를 텍스트 영역에 다운로드
String x="";
try {
conn = DriverManager.getConnection ("jdbc:mysql://localhost/mirroreddatabase", "root", "");
String data=cmbGeneNames.getSelectedItem().toString();
String sql="select * from omimmirrored where symbolGeneSymbol LIKE '%"+data+"%'";//change table
PreparedStatement pst=conn.prepareStatement(sql);
ResultSet rs=pst.executeQuery();
//which checkboxes are checked
while ((rs.next())) {
x = rs.getString("links");
}
conn.close();
}
catch(Exception e) {
JOptionPane.showMessageDialog(null,e);
}
URL u;
InputStream is = null;
DataInputStream dis;
String s;
try {
conn = DriverManager.getConnection ("jdbc:mysql://localhost/mirroreddatabase", "root", "");
String data=cmbGeneNames.getSelectedItem().toString();
u = new URL(x);
is = u.openStream();
dis = new DataInputStream(new BufferedInputStream(is));
while ((s = dis.readLine())!= null) {
//try {
String sql = "update omimmirrored set sequence=? where symbolGeneSymbol LIKE '%"+data+"%'";
PreparedStatement statement=conn.prepareStatement(sql);
statement.setString(1, s);
statement.executeUpdate();
//which checkboxes are checked
//conn.close();
//}
} catch(Exception e) {
JOptionPane.showMessageDialog(null,e);
} finally {
try {
is.close();
} catch (IOException ioe) {
}
try {
conn.close();
}
catch(SQLException sqlException) {
} // end of 'finally' clause
}
당신이 가져 오는 무엇을 ? html 페이지? –
예 html 페이지이지만 내용이 한 줄에 저장되어 있고 단락처럼 저장되기를 원합니다. – user2944911
코드 형식에 더 많은주의를 기울여야하고 catch 절에 무언가가 있어야합니다. 최소한 로깅 –