This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes please, help ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "please, help !" Watch "please, help !" New topic
Author

please, help !

fengqiao cao
Ranch Hand

Joined: Oct 26, 2001
Posts: 71
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

Joined: Oct 26, 2001
Posts: 71
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

Joined: Jan 18, 2001
Posts: 51
Dear Friend ;
It has nothing to do with jdbc its java runtime error


Stop The World I Want To Get Off.
 
 
subject: please, help !
 
Similar Threads
ClassNotFoundException generated!
No Suitible Driver Error
Class.forName() for drive using Oracle 8i
Access to the Oracle database using Java Applets
Error in connection