User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 426,255 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,029 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting

mysql database

Join Date: Mar 2008
Posts: 9
Reputation: nireekshan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
nireekshan nireekshan is offline Offline
Newbie Poster

mysql database

  #1  
Mar 31st, 2008
hai
i am nireekshan;
i am using Mysql 5.0;
it was instaling C:\Program Files\MySQL;
i am write code Bellow see and
--save c:\ "Mysqlcon.java " in this program
run-in commend Fromt> javac Mysqlcon.java It was NOT Any Errer;
>java Mysqlcon
ERRER ACCERED.......CLASS NOT FOUND EXPATION


//I AM COPY Mysql.jar file in C:\

  1. import java.sql.*;
  2.  
  3. public class Mysqlcon{
  4. public static void main(String[] args)
  5. {
  6. System.out.println("MySQL Connect Example.");
  7. Connection conn = null;
  8. String url = "jdbc:mysql://localhost:3306/";
  9. String driver = "com.mysql.jdbc.Driver";
  10. String userName = "";
  11. String password = "";
  12. try {
  13. Class.forName(driver).newInstance();
  14. conn = DriverManager.getConnection(url,userName,password);
  15. System.out.println("Connected to the database");
  16. conn.close();
  17. System.out.println("Disconnected from database");
  18. } catch (Exception e) {
  19. e.printStackTrace();
  20. }
  21. }
  22. }
Last edited by peter_budo : Apr 1st, 2008 at 7:01 am. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 9:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC