Difference between revisions of "Mysql database authentication check"
From MyWiki
(Created page with "<source lang="sql"> Statement stmt = null; ResultSet rs = null; String userName = "argus"; String passWord = "C1n0bbwT"; Stri...") |
|||
Line 1: | Line 1: | ||
+ | This is not stand alone code, it depends of other classes<br> | ||
<source lang="sql"> | <source lang="sql"> | ||
Statement stmt = null; | Statement stmt = null; |
Revision as of 15:13, 9 March 2016
This is not stand alone code, it depends of other classes
Statement stmt = NULL; ResultSet rs = NULL; String userName = "argus"; String passWord = "C1n0bbwT"; String url = "jdbc:mysql://localhost/argus"; try { Class.forName ("com.mysql.jdbc.Driver").newInstance (); conn = DriverManager.getConnection (url, userName, passWord); String getIt = "SELECT user from sessions where session = '"+SESSION.getId()+"'"; stmt = conn.createStatement(); rs = stmt.executeQuery(getIt); IF ( rs.NEXT() ) { String USERNAME = rs.getString("user"); INT LENGTH = USERNAME.LENGTH(); } String ff = SESSION.getId(); String myUrl = "ExtAttrs"; CheckSessionId qq = NEW CheckSessionId(); String ab=qq.checkIt(ff,myUrl); IF ( ab.LENGTH() < 3) response.sendRedirect("login.jsp");