jdbc实践

来源:互联网 发布:淘宝美工一张图多少钱 编辑:程序博客网 时间:2024/05/29 05:54

/*
 * demo.java
 *
 * Created on 2007年2月14日, 下午5:36
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

import java.sql.*;
/**
 *
 * @author Administrator
 */
public class demo {
    
    /** Creates a new instance of demo */
    public demo() {
    }
    public static void main(String[] args){
        try{
            Class.forName("com.mysql.jdbc.Driver");
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hibernate","root","13570578");
        Statement stat = conn.createStatement();
        ResultSet rs = stat.executeQuery("select name from goods");
        int i = 0;
        while(rs.next()){
            System.out.println(rs.getRowId(i).toString());
        }
        }catch(Exception e){
            e.printStackTrace();
        }
        
        
    }
}