java项目部署在linux下的websphere上,想要用jsp显示该服务器上根目录下images文件夹里的一个一张jpg图片 5
1个回答
2015-05-27
展开全部
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class MysqlTest {
public static void main(String[] args) throws Exception {
Connection conn = getConnection();
Statement stmt = conn.createStatement();
ResultSet rst =stmt.executeQuery("select * from gongwenview");
while(rst.next()) {
BigDecimal articleId = rst.getBigDecimal(1);
String title = rst.getString(2);
System.out.println("articleId:\t"+articleId+"\ttitle:\t"+title);
}
System.out.println("查询结束,请继续");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("你输入的内容是:"+reader.readLine());
BufferedReader reader1 = new BufferedReader(new InputStreamReader(System.in));
}
public static Connection getConnection() {
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/gov?characterEncoding=utf-8";
conn = DriverManager.getConnection(url, "root", "test");
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询