在当前工程中用一个类的main方法或者JUnit。运行 String acct="测试数据";
String pwd ="测试数据";
Connection con = null;
Statement st = null;
StringBuffer msgb = new StringBuffer(""); try
{
// These will vary depending on your server/database
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:acctInfo"); Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select balance from acctInfo where account = " +
acct + "and password = '" + pwd + "'");
if (rs.next())
return rs.getString(1);
else
return null;
}
catch (Exception e)
{
return e.toString();
}
String pwd ="测试数据";
Connection con = null;
Statement st = null;
StringBuffer msgb = new StringBuffer(""); try
{
// These will vary depending on your server/database
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:acctInfo"); Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select balance from acctInfo where account = " +
acct + "and password = '" + pwd + "'");
if (rs.next())
return rs.getString(1);
else
return null;
}
catch (Exception e)
{
return e.toString();
}
解决方案 »
- not-null property references a null or transient value
- 使用java.util.regex.Pattern、Matcher(正则表达式)匹配多行sql语句
- 用最有效率的方法算出2乘以8等於几? 为什么是2 < < 3 ?
- ssh
- MyEclipse对于h:commandLink的奇怪问题,竟然点击无效?
- [提问]关于Hibernate执行新增时-->自动检查外键字段的问题??
- 请教:使用schema文件检测xml文件的数据
- 为什么在eclipse里面不能启动jboss哪?
- 问个struts的问题
- ■■请教这段JAVA代码是什么意思,是struts中的,如下■■
- 急!急!急!
- 请问怎么生成WSDL和WSML文件呢?
try
{
// These will vary depending on your server/database
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:acctInfo"); Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select balance from acctInfo where account = " +
acct + "and password = '" + pwd + "'");
stmt.executeQuery("insert into acctInfo values('55','55','55')");//这句是我加上去测试的
if (rs.next())
return rs.getString(1);
else
return null;
}