关于JAVA,谁知道这是怎么回事啊,在代码if(ant_flag=="true") flag=true;中,我读出来ant_flag是true
为什么if(ant_flag=="true")判断不能对flag进行true赋值呢?谢谢啊Stringsql="select*fromRFIDwhereepc='"+ep...
为什么if(ant_flag=="true")判断不能对flag进行true赋值呢?谢谢啊
String sql="select * from RFID where epc='"+epc+"'";
try {
Class.forName(driverName);
conn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("Connection Successful!"); //如果连接成功 控制台输出Connection Successful!
java.sql.Statement cmd =conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String strSql=sql;
ResultSet rs;
rs=cmd.executeQuery(strSql);
if(rs.next())
{
ant_flag = rs.getString(""+str_flag+"");
}
if(ant_flag=="true")
flag=true;
cmd.close();
conn.close();
}catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
return flag; 展开
String sql="select * from RFID where epc='"+epc+"'";
try {
Class.forName(driverName);
conn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("Connection Successful!"); //如果连接成功 控制台输出Connection Successful!
java.sql.Statement cmd =conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String strSql=sql;
ResultSet rs;
rs=cmd.executeQuery(strSql);
if(rs.next())
{
ant_flag = rs.getString(""+str_flag+"");
}
if(ant_flag=="true")
flag=true;
cmd.close();
conn.close();
}catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
return flag; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询