This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Error in  connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error in  connection" Watch "Error in  connection" New topic
Author

Error in connection

Rupashree Kalita
Greenhorn

Joined: Sep 13, 2004
Posts: 1
Hi, The following code is giving continuously error..I requust you to help me. I tried a alot on this code..


import java.sql.*;

public class CreateCoffees {

public static void main(String args[]) {

String url = "jdbc dbc:COFFEES";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME varchar(32), " +
"SUP_ID int, " +
"PRICE float, " +
"SALES int, " +
"TOTAL int)";
Statement stmt;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con = DriverManager.getConnection(url,"sa","");

stmt = con.createStatement();
stmt.executeUpdate(createString);

stmt.close();
con.close();

} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}

[edited to disable smilies]
[ September 13, 2004: Message edited by: Jeanne Boyarsky ]
Giju George
Ranch Hand

Joined: Jun 08, 2004
Posts: 333

Hi, The following code is giving continuously error..I requust you to help me. I tried a alot on this code..


You didn't mention what type of error you are getting!!.
Is your odbc configured correctly... ?
do u have sufficient rights to create tables in the database... ?
what type of database are u using ...?


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in connection
 
Similar Threads
CreateCoffees
No Suitible Driver Error
Access to the Oracle database using Java Applets
ClassNotFoundException generated!
Class.forName() for drive using Oracle 8i