【发布时间】:2014-02-17 07:09:59
【问题描述】:
我正在尝试从 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 页面,但内容存储在一行中,我希望它像段落一样存储。
-
您应该更加注意代码格式并确保在 catch 子句中包含一些内容 - 至少记录日志
标签: java swing joptionpane