Difference between revisions of "Mysql database authentication check"
From MyWiki
Line 3: | Line 3: | ||
Statement stmt = null; | Statement stmt = null; | ||
ResultSet rs = null; | ResultSet rs = null; | ||
− | String userName = " | + | String userName = "xxxxx"; |
− | String passWord = " | + | String passWord = "xxxxxxxxx"; |
String url = "jdbc:mysql://localhost/argus"; | String url = "jdbc:mysql://localhost/argus"; | ||
try { | try { |
Latest revision as of 15:21, 9 March 2016
This is not stand alone code, it depends of other classes
Statement stmt = NULL; ResultSet rs = NULL; String userName = "xxxxx"; String passWord = "xxxxxxxxx"; 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");