筛查一下吧:(当时我学JDBC时总结的,感觉挺管用的)
①SQL2000需要装pack3或以上补丁
②端口号确定1433(SQL网络实用工具里面TCP/IP-属性查看)
③local服务器右键-属性-安全性-身份验证-SQL和Win勾选
④服务管理器,确定已经启动
⑥SQL2000/2005/2008等版本的驱动的路径不一样,jar包别用错了
//这是我以前写的核对数据库实现登陆的方法,你只看jdbc部分就好,我还特地给你加了点注释\x0d\String sql = "select username,password from account";\x0d\String user = requestgetParameter("user");\x0d\String pass = requestgetParameter("password");\x0d\int j = 0;\x0d\Connection conn = null;\x0d\PreparedStatement ps = null;\x0d\ResultSet rs = null;\x0d\try {\x0d\conn = JDBCTools1getConnection();\x0d\ps = connprepareStatement(sql);\x0d\rs = psexecuteQuery();\x0d\//从表中查询获取所有账户的用户名&密码的ResultSet 对象\x0d\while(rsnext()){\x0d\int i = 0;\x0d\\x0d\String username[] = new String[10];//用户名数组\x0d\String password[] = new String[10];//密码数组\x0d\username[i] = rsgetString(1);\x0d\password[i] = rsgetString(2);\x0d\if(userequals(username[i])&&passequals(password[i])){//比对\x0d\responsegetWriter()print("you are welcome!");\x0d\j++;\x0d\}else if(userequals(username[i])&&!passequals(password[i])){\x0d\responsegetWriter()println("the realy password is :"+ username[i] +","+password[i]+"\r\n");\x0d\responsegetWriter()println("and you password is :"+user +","+pass+" :so the username or password may not right");\x0d\j++;\x0d\}else{\x0d\continue;\x0d\}\x0d\i++;\x0d\}\x0d\if(j == 0){\x0d\responsegetWriter()println("Your username may not be properly");\x0d\}\x0d\} catch (Exception e) {\x0d\eprintStackTrace();\x0d\}finally{\x0d\JDBCTools1release(rs, ps, conn);\x0d\}\x0d\//这是我JDBCTools的getConnection方法\x0d\getConnection{\x0d\String driverClass = oraclejdbcdriverOracleDriver;\x0d\String jdbcUrl = jdbc:oracle:thin:@localhost:1521:orcl;\x0d\//你的数据库的用户名密码\x0d\String user = null;\x0d\String password = null;\x0d\// 通过反射创建Driver对象\x0d\ClassforName(driverClass);\x0d\return DriverManagergetConnection(jdbcUrl, user, password);}\x0d\//这是我JDBCTools的release方法\x0d\public static void release(ResultSet rs, Statement statement,\x0d\Connection conn) {\x0d\if (rs != null) {\x0d\try {\x0d\rsclose();\x0d\} catch (SQLException e) {\x0d\eprintStackTrace();\x0d\}\x0d\}\x0d\\x0d\if (statement != null) {\x0d\try {\x0d\statementclose();\x0d\} catch (Exception e2) {\x0d\e2printStackTrace();\x0d\}\x0d\}\x0d\\x0d\if (conn != null) {\x0d\try {\x0d\connclose();\x0d\} catch (Exception e2) {\x0d\e2printStackTrace();\x0d\}\x0d\}\x0d\}
以上就是关于JAVA连接数据库登陆不了全部的内容,包括:JAVA连接数据库登陆不了、java链接mysql数据库实现登陆如何验证、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)