Share on Google+Share on Google+

Shibin Varghese
java.lang.UnsupportedOperationException
1 Answer(s)      7 years ago
Posted in : JSP-Servlet

Ads

View Answers

November 26, 2009 at 12:46 PM


Hi Friend,

We are providing you the code where we have used MySql database.

Use the following code:

<[email protected] import="java.io.*"%>
<[email protected] import="java.sql.*"%>
<%
String connectionURL = "jdbc:mysql://localhost:3306/test";;;
Connection con=null;
Statement stmt = null;
ResultSet rs = null;
Blob image = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";;);
stmt = con.createStatement();
rs = stmt.executeQuery("select image from image where image_id =1");
if (rs.next()) {
image = rs.getBlob(1);
}
File f=new File("C:\\newImage.jpg");
FileOutputStream fos=new FileOutputStream(f);
InputStream in = image.getBinaryStream();
int length = (int) image.length();
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
while ((length = in.read(buffer)) != -1) {
fos.write(buffer, 0, length);
}
out.println("Image is saved into the file.");
in.close();
fos.close();
} catch (Exception e){}
finally {
try {
rs.close();
stmt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
%>

Hope that it will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
java.lang.UnsupportedOperationException - JSP-Servlet
java.lang.UnsupportedOperationException   Hi friends, Thank you for the support you have provided to me until now. now I am in a problem.... But now it is giving exception "java.lang.UnsupportedOperationException
how to solve an internet connection problem
how to solve an internet connection problem  when i run my application it give me this error: Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not yet implemented the problem is that i don`t know
Advertisements
jsf application war file not running in my jboss 6.0 on linux 5.5
Faces Servlet threw exception: java.lang.UnsupportedOperationException
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads