MySQL Forums
Forum List  »  Microsoft SQL Server

Unable to insert data on a remote system using java program
Posted by: rahul c
Date: March 09, 2010 12:19PM

Hello All,

I am trying to run a java program on a remote system to insert data onto a remote MySQL server.This program runs fine on my local system and inserts data onto my local SQL server but when I run it on the remote system using the commands below,I get the following error:

copperhead$ javac -classpath Project/mysql-connector-java-5.1.10-bin.jar database_creation.java

copperhead$ java database_creation

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at database_creation.<init>(database_creation.java:13)
at database_creation.main(database_creation.java:46)


I am attaching the java program code I am using to insert the data.

import java.sql.*;
import java.io.*;
import java.util.*;
import java.net.*;
public class database_creation
{
public database_creation() throws Exception
{

try
{
//connecting to the data base
//This is where exception is being thrown
Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection con=DriverManager.getConnection("jdbc:mysql://mysql.cs.abc.edu:3306/databasename","username","password");
Statement stmt=con.createStatement();
Statement stmt1=con.createStatement();
Statement stmt2=con.createStatement();

String str1="DROP TABLE IF EXISTS bookmark_training;";
String str_type="SET NAMES 'utf8';";
String create_bookmark="CREATE TABLE bookmark_training ("
+"`content_id` int(10) unsigned NOT NULL default '0',"
+"`url_hash` varchar(32) NOT NULL default '',"
+"`url` text NOT NULL,"
+"`description` text NOT NULL,"
+"`extended` text,"
+"`date` datetime NOT NULL default '1815-12-10 00:00:00'"
+") CHARSET=utf8;";

String load_bookmark="load data INFILE 'Tables/Dc_Train09/2009-01-01_cleaned/bookmark' INTO TABLE bookmark_training;";

stmt.executeUpdate(str1);
stmt.executeUpdate(str_type);
stmt.executeUpdate(create_bookmark);

stmt.executeUpdate(load_bookmark);
}
catch(Exception exc)
{
exc.printStackTrace();
}
}
public static void main(String[] args) throws Exception
{
database_creation d2=new database_creation();

}
}


I would be grateful to you if you can help me resolve this issue.

Options: ReplyQuote


Subject
Written By
Posted
Unable to insert data on a remote system using java program
March 09, 2010 12:19PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.