package cracle;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Oracle
{
public static void main(String[] args) throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:byqiuxi","tt","tt");<br>//本机,服务名,用户,密码
//这个是插入的
PreparedStatement ps=connection.prepareStatement(" insert into buy values(?,?,?)");
ps.setString(1, "2");
ps.setString(2, "dd");
ps.setString(3, "ddd");
ps.executeUpdate();
//这个是查询的
Statement st= connection.createStatement();
ResultSet rs= st.executeQuery("select * from buy");
while(rs.next())
{
System.out.println("33333");
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
}
}
}