怎么在java中判断一个数据库中是否存在表user

怎么在java中判断一个数据库中是否存在表user,第1张

方法有二:
1、查询表user,如果抛出表存在的异常,就证明表user不存在
2、查询系统表,每种数据库都有一张系统表,用该存放数据库中的所有表的信息。
你只需要查询系统表有无该表的记录即可。但是不同种类的数据库,系统表可能不一样。

您好,提问者:
对象有引用地址,因为String也是一个字符串,所以你这样比较的话肯定不想等。
String比较内容要用equals(),比如你的代码:nameequals(name==s[1])

package test1;
public class J {
public static void main(String[] args) {
int i[] = { 0100, 0011, 1110, 0110, 1000 };
int i3 = 0;
for (int i1 : i) {
int i2 = 1;
while (i2 < ilength + 1) {
i3 = i1 >> i2;
if (i3 == i1) {
Systemoutprintln("右移:\t" + i3 + "存在数组中");
}else {
Systemoutprintln("右移:\t" + i3 + "不存在数组中");
}
i3 = i1 << i2;
if (i3 == i1) {
Systemoutprintln("左移:\t" + i3 + "存在数组中");
}else {
Systemoutprintln("左移:\t" + i3 + "不存在数组中");
}
i2++;
}
}
}
}

做了个注册页面,验证用户是否 存在 总是显示出错 代码如下:private int UserChecked(){SqlConnection conn = new SqlConnection(@"server=烟客少爷;database=Register;Trusted_Connection=True");SqlCommand cmd = new SqlCommand("Select from Register where userID='"+tb_userNameTextTrim()+"'", conn);int i = 0;try{connOpen();SqlDataReader sdr= cmdExecuteReader();if (sdrRead ()){i = 1;Label1Text = "用户名已经存在!";}else{Label1Text = "恭喜你,此用户名可用!";}}catch (SystemException ee){//ResponseWrite ("<script language=javascriptalert('"+eeMessageToString()+"')</script");}finally{connClose();}return i;}显示 SqlCommand cmd = new SqlCommand("Select from Register where userID='"+tb_userNameTextTrim()+"'", conn);这里有错。就是检查数据库中是否存在这个用户名;我新手拜托了有这样例子的代码更好


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/yw/13399594.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-29
下一篇 2023-07-29

发表评论

登录后才能评论

评论列表(0条)

保存