Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please, help !

 
fengqiao cao
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, everyone
i am pretty new to JDBC and i try to creat a table called COFFEES in the COFFEEBREAKTRY databas which exits in my sql server. The following program seems ok to me however i got erro :Exception in thread "main" java.lang.NoClassdefFounderError:creatCoffee.
could anyone help me out? (many thanks).

import java.sql.*;
import java.util.Properties;
public class CreateCoffees {
public static void main(String args[]) {
String url = "jdbc:weblogic:mssqlserver4";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME varchar(32), " +
"SUP_ID int, " +
"PRICE float, " +
"SALES int, " +
"TOTAL int)";
Statement stmt;
Properties props = new Properties();
props.put("user", "caofengqiao");
props.put("password", "8801386");
props.put("server", "COFFEEBREAKTRY@CFQ-YQ1RKQ9LSD7:1433");
//database name=COFFEEBREAKTRY,Server=CFQ-YQ1RKQ9LSD7
try {
Class.forName("weblogic.jdbc.mssqlserver4.Driver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,props);
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
 
fengqiao cao
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Finally, i found out that there is nothing wrong with the code.
However, it is becuause the CLASSPATH problem.
I came from windows me to windows 2000. There is huge different(ha...) when dealing with CLASSPATH(In windows 2000 , if u want to run java application you must set the CLASSPATH but now in windows me) ha.....
hope this help the newbies like me....
 
sharad goswami
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friend ;
It has nothing to do with jdbc its java runtime error
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic