The following code is what I find on website, and I have changed the < > to my db information, but it still not work, I guess it is sth wong with jdbc
import java.io.*;
import java.sql.*;
class Sample
{
public static void main(String ds[])
{
Connection con=null;
Statement st=null;
ResultSet rs=null;
String FirstName="";
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance ();
con=DriverManager.getConnection("jdbc:mysql://<ip>/<dbname>","root","password");
st=con.createStatement() ;
rs=st.executeQuery("SELECT <field> FROM <table>") ;
while(rs.next())
{
FirstName=rs.getString(1);
char[] email1;
System.out.println(<field>);
}
}
catch(Exception eer)
{
System.out.println(eer.toString());
}
}
}
Ther ERROR I got:
java.lang.NoClassDefFoundError: asia/hpi/hr/Sample
Caused by: java.lang.ClassNotFoundException: asia.hpi.hr.Sample
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
and I have a problem with jdbc, I download the jdbc, but I dunno where should I put the library (my default path at d:/java)
can anyone please help?
import java.io.*;
import java.sql.*;
class Sample
{
public static void main(String ds[])
{
Connection con=null;
Statement st=null;
ResultSet rs=null;
String FirstName="";
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance ();
con=DriverManager.getConnection("jdbc:mysql://<ip>/<dbname>","root","password");
st=con.createStatement() ;
rs=st.executeQuery("SELECT <field> FROM <table>") ;
while(rs.next())
{
FirstName=rs.getString(1);
char[] email1;
System.out.println(<field>);
}
}
catch(Exception eer)
{
System.out.println(eer.toString());
}
}
}
Ther ERROR I got:
java.lang.NoClassDefFoundError: asia/hpi/hr/Sample
Caused by: java.lang.ClassNotFoundException: asia.hpi.hr.Sample
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
and I have a problem with jdbc, I download the jdbc, but I dunno where should I put the library (my default path at d:/java)
can anyone please help?