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 373,375 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 3,802 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
Views: 467 | Replies: 7
Reply
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  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,026
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 227
nav33n's Avatar
nav33n nav33n is online now Online
Posting Sensei

Re: mysql database

  #2  
Mar 31st, 2008
Post your question in java forum to get better response
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,897
Reputation: peter_budo has a spectacular aura about peter_budo has a spectacular aura about peter_budo has a spectacular aura about 
Rep Power: 9
Solved Threads: 216
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Posting Virtuoso

Re: mysql database

  #3  
Apr 1st, 2008
@nireekshan - your post is moved to Java section of forum

@na33n and others - if you find post to be in wrong section of the forum, just click on Flag Bad Post and type something like Please move this post to Java forum for example and moderators will deal with it

Thank you
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,026
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 227
nav33n's Avatar
nav33n nav33n is online now Online
Posting Sensei

Re: mysql database

  #4  
Apr 1st, 2008
Okay ! I thought flag bad post was to notify the moderators that the post has violated the rules. Thanks for clarifying !
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,897
Reputation: peter_budo has a spectacular aura about peter_budo has a spectacular aura about peter_budo has a spectacular aura about 
Rep Power: 9
Solved Threads: 216
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Posting Virtuoso

Re: mysql database

  #5  
Apr 1st, 2008
Flag Bad Post is marking a post if something is not in order from spam, wrong forum, request for help through email or phone, basicly anything what may be in your opinion against forum rules. Once we recieve report, we check it and make decision
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,026
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 227
nav33n's Avatar
nav33n nav33n is online now Online
Posting Sensei

Re: mysql database

  #6  
Apr 1st, 2008
oh cool ! Will do that in future.. Cheers man!

Hey, I saw this in "Flag bad post" !

Note: This is ONLY to be used to report spam, advertising messages, and problematic (harassment, fighting, or rude) posts.
Last edited by nav33n : Apr 1st, 2008 at 7:44 am.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,486
Reputation: Ezzaral is just really nice Ezzaral is just really nice Ezzaral is just really nice Ezzaral is just really nice 
Rep Power: 9
Solved Threads: 251
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Nearly a Posting Maven

Re: mysql database

  #7  
Apr 1st, 2008
Originally Posted by nireekshan View Post
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:\


Try running it with java -cp .;mysql-connector-java-[ver]-bin.jar Mysqlcon. You need to have the jar file in your classpath for it to find the files.
You may want to read this documentation as well: http://dev.mysql.com/doc/refman/5.0/...classpath.html
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,026
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 227
nav33n's Avatar
nav33n nav33n is online now Online
Posting Sensei

Re: mysql database

  #8  
Apr 1st, 2008
Originally Posted by Ezzaral View Post
Try running it with java -cp .;mysql-connector-java-[ver]-bin.jar Mysqlcon. You need to have the jar file in your classpath for it to find the files.
You may want to read this documentation as well: http://dev.mysql.com/doc/refman/5.0/...classpath.html


[offtopic] Hi "Featured poster" of the month [/offtopic]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 2:59 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC