CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 image insertion problem

Print topic Send  topic

Author Message
fredrick

Posts: 4
Posted: 03/04/2010, 7:18 PM

Hello can someone help me. Am new in java
i want to insert image with this code but it displays an error stated below

C:\Tomcat 6.0\webapps\form2\WEB-INF\classes>javac Main.java

C:\Tomcat 6.0\webapps\form2\WEB-INF\classes>java Main
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driv
er
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at Main.main(Main.java:11)

C:\Tomcat 6.0\webapps\form2\WEB-INF\classes>


I entered mysql connector at j.d.k.6.0/lib just as i do at tomcat/lib but am still recieving the same thing. Plz help me.

here is the code .Thanks and regards


import java.io.File;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class Main {
public static void main(String[] argv) throws Exception {
File file = new File("C:/Tomcat 6.0/webapps/form2/image/esedo.gif");
FileInputStream fis = new FileInputStream(file);
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost/love", "root", "root");
conn.setAutoCommit(false);
PreparedStatement ps = conn
.prepareStatement("insert into images values (?,?)");
ps.setString(1, file.getName());
ps.setBinaryStream(2, fis, (int) file.length());
ps.executeUpdate();
ps.close();
fis.close();

}
}


_________________
THANKS
View profile  Send private message
fredrick

Posts: 4
Posted: 03/07/2010, 4:35 PM

Dont bother again it has been resolved. thanks
_________________
THANKS
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.