⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqlshoppingcarttest.java

📁 著名的uncle Bob的Agile software development的代码
💻 JAVA
字号:
import junit.framework.*;
import java.sql.*;

public class SqlShoppingCartTest extends TestCase
{
    public static void main(String[] args)
    {
      junit.swingui.TestRunner.main(new String[] {"SqlShoppingCartTest"});
    }
	public SqlShoppingCartTest(String name)
	{
		super(name);
	}
	
	private Connection c;
	private Statement s;
	
	public void setUp() throws Exception
	{
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // load driver
		c = DriverManager.getConnection("jdbc:odbc:PPP Shopping Cart");
		s = c.createStatement();
	}
	
	public void tearDown() throws Exception
	{
		s.executeUpdate("Delete from Customers where cusid = 0");
		c.close();
	}
	
	public void testReadWrite() throws Exception
	{
		s = c.createStatement();
		s.executeUpdate("Insert into Customers values (0,'Bob', '14619', 'amex')");
		ResultSet rs = s.executeQuery("Select * from Customers where cusid = 0");
		rs.next();
		assertEquals("Bob", rs.getString("name"));
		assertEquals("14619", rs.getString("address"));
		assertEquals("amex", rs.getString("billing information"));
		rs.close();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -