import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class demo123
{
public static void main(String[] args)
{
try
{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("class found");
Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test","root","root");
System.out.println("class found1");
PreparedStatement ps = con.prepareStatement("select (password) from users where username= ? ");
ps.setString(1, "vishal");
ResultSet rs = ps.executeQuery();
if(rs.next())
{
String pass=rs.getString(1);
System.out.println("pss->"+pass);
}
} catch (Exception e)
{
System.out.println("Exception--->"+e);// TODO: handle exception
}
}
}
No comments:
Post a Comment