4

i am trying to access database with DataSource , for configuring datasource i need to import com.mysql.jdbc.jdbc2.optional.MysqlDataSource but the problem is that Netbeans doesn't recognize it , saying that package doesn't exist.

(i installed java jdk v.8 , and i am using Netbeans IDE v8.0.2)

reza71
  • 37
  • 1
  • 3

1 Answers1

6

Download MySql JDBC Jar file from here and follow the steps below.

Here are screenshots for you.

  • Add the JAR file in your Project by Right Click on your Project's Library folder

enter image description here

  • Add Jar/Folder, Browse the Jar file and add it.

enter image description here

  • Import com.mysql.jdbc.jdbc2.optional.MysqlDataSource . Done.

enter image description here

Hope it helps.

rhitz
  • 1,892
  • 2
  • 21
  • 26
  • You are welcome, Please accept the answer if your problem is solved, as it will help the future users. – rhitz Aug 09 '15 at 15:54
  • i did it , i am new to the site , i didn't know about the acceptance , otherwise i would have done it in the first place. – reza71 Aug 09 '15 at 16:16
  • look , is there any way to use this package so i wouldn't have to import it each time i am gonna use it in a prjoect. i mean like the usual packages that we use ?should i put it in the classpath? – reza71 Aug 09 '15 at 16:21
  • see this , http://stackoverflow.com/questions/4911554/how-to-tell-eclipse-to-include-standard-jar-library-for-all-projects – rhitz Aug 09 '15 at 16:46
  • and this http://stackoverflow.com/questions/4911554/how-to-tell-eclipse-to-include-standard-jar-library-for-all-projects – rhitz Aug 09 '15 at 16:47