public class DemoBlob
{
public static void main(String args[])throws Exception
{
Class.forName("com.mysql.jdbc.Driver"); //type 4 driver
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/college","root","rat");//connection
System.out.println("Connection successful:"+con);
PreparedStatement ps=con.prepareStatement("select * from login");
ResultSet res=ps.executeQuery();
res.next();
Blob b= res.getBlob(1);
long len=b.length();
byte value[]=b.getBytes(1, (int)(len));
String str=new String(value);
System.out.println(str);
}
}
No comments:
Post a Comment