/**
*
*/
package com.ccniit.bookshop.db;
import java.sql.*;
/**
* @author WANG
*
*/
public class GetBookByID {
/**
* @param args
*/
public static void main(String[] args) {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
//******************************
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433; databaseName=bookshop","sa","123");
PreparedStatement pst =con.prepareStatement("select * from book where book_id=?");
pst.setInt(1,2);
ResultSet rs=pst.executeQuery();//返回的是ResultSet
while (rs.next())
{ int bookid=rs.getInt("book_id");
String bookname=rs.getString("book_name");
System.out.println("book_id="+bookid,"book_name="+bookname);
}
rs.close();
pst.close();
con.close();
}
}
[此贴子已经被作者于2006-10-16 15:32:16编辑过]
----------------解决方案--------------------------------------------------------
没有这种形式的
System.out.println(String,String);
分写两句
System.out.println("your data");
----------------解决方案--------------------------------------------------------
谢谢拉,弄好拉
----------------解决方案--------------------------------------------------------