when i run my code using IDE it run fine but when i run it using command prompt
it show following errors

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd\

C:\>cd bank2

C:\bank2>javac *.java
CurrentTransaction.java:2: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Connection;
^
CurrentTransaction.java:3: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Statement;
^
login.java:2: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Connection;
^
login.java:3: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Statement;
^
CustomerDetailLogin.java:2: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Connection;
^
CustomerDetailLogin.java:3: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Statement;
^
CustomerTransaction.java:1: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Connection;
^
CustomerTransaction.java:2: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Statement;
^
CurrentTransaction.java:155: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.
0.0.1:3306/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:155: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.
0.0.1:3306/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:156: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:156: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:174: error: cannot find symbol
Connection cn=(Connection) DriverManager.getConnection(url1,
"root","rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:174: error: cannot find symbol
Connection cn=(Connection) DriverManager.getConnection(url1,
"root","rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:175: error: cannot find symbol
Statement stmt=(Statement) cn.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:175: error: cannot find symbol
Statement stmt=(Statement) cn.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:194: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhos
t/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:194: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhos
t/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:195: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:195: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:229: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhos
t/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:229: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhos
t/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:230: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:230: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
login.java:105: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class login
login.java:105: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class login
login.java:106: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class login
login.java:106: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class login
CustomerDetailLogin.java:105: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class CustomerDetailLogin
CustomerDetailLogin.java:105: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class CustomerDetailLogin
CustomerDetailLogin.java:106: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CustomerDetailLogin
CustomerDetailLogin.java:106: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CustomerDetailLogin
CustomerTransaction.java:101: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class CustomerTransaction
CustomerTransaction.java:101: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class CustomerTransaction
CustomerTransaction.java:102: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CustomerTransaction
CustomerTransaction.java:102: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CustomerTransaction
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
36 errors

C:\bank2>

why?

note : when i run other(which not require database operations) code using prompt they run successfully.

when i run my code using IDE it run fine but when i run it using command prompt
it show following errors

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd\

C:\>cd bank2

C:\bank2>javac *.java
CurrentTransaction.java:2: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Connection;
^
CurrentTransaction.java:3: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Statement;
^
login.java:2: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Connection;
^
login.java:3: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Statement;
^
CustomerDetailLogin.java:2: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Connection;
^
CustomerDetailLogin.java:3: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Statement;
^
CustomerTransaction.java:1: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Connection;
^
CustomerTransaction.java:2: error: package com.mysql.jdbc does not exist
import com.mysql.jdbc.Statement;
^
CurrentTransaction.java:155: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.
0.0.1:3306/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:155: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.
0.0.1:3306/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:156: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:156: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:174: error: cannot find symbol
Connection cn=(Connection) DriverManager.getConnection(url1,
"root","rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:174: error: cannot find symbol
Connection cn=(Connection) DriverManager.getConnection(url1,
"root","rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:175: error: cannot find symbol
Statement stmt=(Statement) cn.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:175: error: cannot find symbol
Statement stmt=(Statement) cn.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:194: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhos
t/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:194: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhos
t/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:195: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:195: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:229: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhos
t/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:229: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhos
t/bank","root", "rushikesh");
^
symbol: class Connection
location: class CurrentTransaction
CurrentTransaction.java:230: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
CurrentTransaction.java:230: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CurrentTransaction
login.java:105: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class login
login.java:105: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class login
login.java:106: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class login
login.java:106: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class login
CustomerDetailLogin.java:105: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class CustomerDetailLogin
CustomerDetailLogin.java:105: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class CustomerDetailLogin
CustomerDetailLogin.java:106: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CustomerDetailLogin
CustomerDetailLogin.java:106: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CustomerDetailLogin
CustomerTransaction.java:101: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class CustomerTransaction
CustomerTransaction.java:101: error: cannot find symbol
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://loca
lhost/bank","root", "rushikesh");
^
symbol: class Connection
location: class CustomerTransaction
CustomerTransaction.java:102: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CustomerTransaction
CustomerTransaction.java:102: error: cannot find symbol
Statement stmt = (Statement) con.createStatement();
^
symbol: class Statement
location: class CustomerTransaction
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
36 errors

C:\bank2>

why?

note : when i run other(which not require database operations) code using prompt they run successfully.

You need to add MySQL Driver in your classpath for that , and import appropriate classes/libraries to your source.

commented: the classpath to completenis is not found in the IDE ... (old chinese saying - or should be ;) ) +14

when i run this code on command prompt it work fine

import java.sql.*;

public class MySQLDatabase{

public static void main(String args[]){
String dbtime;
String dbUrl = "jdbc:mysql://localhost/bank";
String dbClass = "com.mysql.jdbc.Driver";
String query = "desc customer";

try {

Class.forName("com.mysql.jdbc.Driver");

Connection con = DriverManager.getConnection(dbUrl,"root", "rushikesh");
//Connection con = DriverManager.getConnection (dbUrl,"rushikesh");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {
dbtime = rs.getString(1);
System.out.println(dbtime);
} //end while

con.close();
} //end try

catch(ClassNotFoundException e) {
e.printStackTrace();
}

catch(SQLException e) {
e.printStackTrace();
}

}  //end main

}  //end class

so i think there is not any mysql driver problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.