Java Eclipse GUI Tutorial 4 # Database Connection ( Sqlite ) to Java Part 2 of 2

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 116

  • @aditirajendran4158
    @aditirajendran4158 8 років тому +13

    For those who can't run the program,this one worked for me.
    1. not all libraries are mandatory, i used 3.7.15-SNAPSHOT-2
    2.also put the database into ur java workspace,
    it runs for me..

    • @mechicanotv2751
      @mechicanotv2751 7 років тому

      yep this worked for me too!

    • @anujsinghsomvanshi3385
      @anujsinghsomvanshi3385 7 років тому

      there is show an error in Login ->import.javax.swing.*;
      help me pls

    • @nathannorton1950
      @nathannorton1950 5 років тому

      @@anujsinghsomvanshi3385 you wrote it wrong. Remove the first period,
      Is should be:
      import. javax.swing,*;

  • @michaelvigato3228
    @michaelvigato3228 6 років тому +1

    Thanks for the tutorial.
    I used to get an SQLException error message and I fixed it this way:
    1. Move your database file (mydatabase.db, mydatabase.sqlite or whatever is called) to your ecplise workspace's main folder
    (in my case the database will be located to C:\Users\Michael\eclipse-workspace\Company\sampleDB.sqlite)
    2. Modify (in class sqliteConnection) your DriverManager.getConnection argument accordingly. In my case:
    Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\Michael\\eclipse-workspace\\Company\\sampleDB.sqlite");
    3. Run
    Also, you don't need ALL the .jar files.
    You can simply download the latest one (for me it was sqlite-jdbc-3.23.1)

  • @rivalz4806
    @rivalz4806 6 років тому

    For people getting "the system cannot find the path specified" error this is what I did:
    This is my path C:\\Users\\malco\\Desktop\\Eclipse Workspace\\Company\\EmployeeData.sqlite
    but whenever I would copy and paste this path elsewhere in quotes I would get this:
    "C:\\\Users\\\malco\\Desktop\\\Eclipse Workspace\\\Company\\\EmployeeData.sqlite"
    So I literally opened a text file and manually copied the file path there in hopes of cleaning up the invisible characters and pasted that back in my code.
    This solution worked for me after hours of looking for a solution :)
    Hope this helps

  • @DainiusDainius
    @DainiusDainius 10 років тому +3

    You can download only sqlite-jdbc-3.8.7.jar Then right click on JRE System Library->Build Path->Configure Build Path and press "Add External JAR's".
    But video is stil great. Thanks.

    • @ama9389
      @ama9389 9 років тому

      Daynewss I've downloaded sqlite-jdbc-3.8.7.jar and did the following as stated above but i still received the same error. FYI, i'm using MySQL Workbench.

    • @ama9389
      @ama9389 9 років тому

      Daynewss It's ok brother. I got it all sorted out. :P

  • @MondaySurprise
    @MondaySurprise 10 років тому +21

    Uh... Add one jar file is totally enough, I've added this: sqlite-jdbc-3.8.7.jar

  • @ramnarayanpatro1772
    @ramnarayanpatro1772 8 років тому

    Very beneficial, i have started from first... one thing i cal tell here is that you don't have to add all the JAR files. you just add the latest version of JAR ...

  • @neopect7042
    @neopect7042 4 роки тому +1

    UPDATED LINKS: github.com/xerial/sqlite-jdbc bitbucket.org/xerial/sqlite-jdbc/downloads/
    Project has been moved by dev

  • @NeSsBeZz
    @NeSsBeZz 6 років тому

    Thank you. After 2 tries, my connection was successful.

  • @bluehornet6752
    @bluehornet6752 9 років тому +1

    You could also have clicked the "Add External JARs" button and done the same thing. That would have allowed you to browse to the location of the SQLite JAR file, and it would then have been added. You didn't need to go to the trouble of creating a Resources directory and copying over all those JAR files.

  • @ProgrammingKnowledge
    @ProgrammingKnowledge  10 років тому

  • @timeeternity3620
    @timeeternity3620 10 років тому

    Its add external jar by the add jar and you should learn video editing and cut some unneeded parts. But the tutorial was helpful! Thanxs

  • @whymerizza
    @whymerizza 8 років тому

    Great instruction! Thanks. Haven't done the same exercise, but it makes sense for a newb like me.

  • @nordiskUSA
    @nordiskUSA 9 років тому

    thanks! You can also add external Jar instead of creating the Folder :)
    too bad there are some mistakes on the tutorial which makes the learning a bit confusing!

  • @sevantaheri4831
    @sevantaheri4831 7 років тому

    Great tutorial. Very easy to follow and very informative.

  • @arnemyggen
    @arnemyggen 9 років тому +2

    Really helpful tutorial but maybe you should delete the chaos regarding the JDCB drivers and upload again.

  • @emachete1
    @emachete1 8 років тому

    Excellent this code is real easy to understand thanks.

  • @makeawsome5155
    @makeawsome5155 6 років тому

    Awesome!! i did it successfully, thank you so much!

  • @mmikhan
    @mmikhan 7 років тому

    In order to get the SQLite database file path, it's best to use the Path class to ensure you're using an absolute path instead of hard coding the path manually.
    import java.nio.file.Path;
    import java.nio.file.Paths;
    import java.nio.file.LinkOption;
    Path path = Paths.get("database.sqlite");
    Path reaPath = path.toRealPath(LinkOption.NOFOLLOW_LINKS);

  • @anwaarahmad7660
    @anwaarahmad7660 9 років тому

    Thank you this video is very helpfull👍

  • @lukabirtasevic2680
    @lukabirtasevic2680 10 років тому

    Thanks a lot for this tutorials , they are really helpfull !

  • @martilrap
    @martilrap 9 років тому +1

    Thank you, that's very useful ..

  • @patrickedwinmoran2966
    @patrickedwinmoran2966 6 років тому

    I think something may have changed since you made this tutorial. I have gone over the coding several times. You haven't provided a typed-out tutorial so possibly I've missed something. There were a couple of errors that I had to correct (wouldn't be accepted by current Eclipse). One error remains: It doesn't like"getConnection" in "DriveManager.getConnection."

  • @pristoid
    @pristoid 9 років тому

    Thanks. You are Rock!!

  • @nabeelm7
    @nabeelm7 9 років тому +1

    Thank you, that's very usefu

  • @iheanachoallison9378
    @iheanachoallison9378 10 років тому +1

    Thank you very very Much

  • @megamanepicness3852
    @megamanepicness3852 9 років тому

    U are a boss! Thanks!

  • @duyejamilla6897
    @duyejamilla6897 7 років тому

    Guys if you copy and paste the path from the explorer this will give you an error, i suggest to just write it on to avoid the hidden white spaces from the explorer.

  • @johandijohandi212
    @johandijohandi212 7 років тому

    thanks for the tutorial

  • @ama9389
    @ama9389 9 років тому

    Thanks brother!

  • @nathannorton1950
    @nathannorton1950 5 років тому

    Here is my source code. Note that it is slightly different from the program given in the tutorial. Java changes over time and some things that were o.k. before now create problems:
    import java.sql.*;
    import javax.swing.*;
    import java.sql.Connection;
    //Needs JAR file so create folder called "Archive" or whatever, and copy the required
    //jar file into that folder. Go to tutorial for explanation of how to have it included
    //into the program in a proper manner.
    public class sqliteCoNNection {
    public static Connection dbConnector(){
    Connection conn = null;
    try {
    Class.forName("org.sqlite.JDBC");
    conn=DriverManager.getConnection("jdbc:sqlite:/Users/johnpauljones/Bruin.sqlite");
    //The line above can't start with Connection conn.
    JOptionPane.showMessageDialog(null, "Followed above path successfully.");
    return conn;
    }catch (Exception e)
    {
    JOptionPane.showMessageDialog(null, "Exception to sqliteConnection process experienced");
    return null;
    }
    }
    }

  • @nathannorton1950
    @nathannorton1950 5 років тому

    One problem that only bit me much later on. When you run this program with a database name that does not exist, this program (as a matter of just the way sqLite works) will *create* an empty DB file on your computer where you were looking for it.

  • @mequanentargaw
    @mequanentargaw 7 років тому

    Thank you so much!!!!!!!!

  • @ladagang
    @ladagang 9 років тому

    This is good!

  • @royemmanuel4362
    @royemmanuel4362 8 років тому

    you dont really need to do all those downloads,just add any sqlite-jdbc ...
    easiest way project properties,java build path,add external jar

  • @hannataha8269
    @hannataha8269 8 років тому +1

    Who are those 10 haters?? Everything is explained in a very clear manner!

  • @geraldibra3635
    @geraldibra3635 7 років тому +16

    mvnrepository.com/artifact/org.xerial/sqlite-jdbc/3.8.7
    Just download the above and do what he does with all those libraries problem fixed...took me sometimes to find this. You are welcome!

  • @ThePatternJugglers
    @ThePatternJugglers 8 років тому

    Instead of outputting the connection successful to a pop up dialog, how would you set a JLabel on the login JPanel to set its text to connection successful?

  • @nagashivudu2090
    @nagashivudu2090 7 років тому

    Do the repository compulsory????

  • @jesche6240
    @jesche6240 6 років тому

    Hy,
    good tutorials! I like them a lot!
    when starting the programm in Eclipse, everything is fine, but if you create a runnable jar, the org.sqlite.jdbc can not be found. Can you advice?
    Thx a lot

    • @northpoleneon3214
      @northpoleneon3214 4 роки тому

      Make sure you got your file paths right and you packaged the libraries not extract them

  • @gnasamx
    @gnasamx 8 років тому

    it's throwing exception "java.sql.SQL.Exception:the database has been closed" ?

  • @carlc2268
    @carlc2268 9 років тому

    why do you download all the diff versions of jars, ;)

  • @shubhamr605
    @shubhamr605 6 років тому

    why not you used Mysql and what will be differences in command if i use mysql instead of sqlite

  • @daudbalogun5984
    @daudbalogun5984 6 років тому

    pls help me ,am getting java.sql.SQLEXCEPTION:No suitable driver found for..............

  • @pixemsoft7657
    @pixemsoft7657 6 років тому

    This jar fils also need in Mysql please tell me? If this need then tell me from where we can downlaod this.

  • @ZombiesAndCallOfDuty
    @ZombiesAndCallOfDuty 8 років тому

    Hey i'm on mac and i did all the steps and I have no errors but my program doesnt show the message that the connection is successful and only the blank login screen pops up, what should i do?

  • @jaydave8063
    @jaydave8063 10 років тому +1

    What if I have to refer to a database stored in my Package? I want to maintain my database in my source folder so that if I run the same application on my friend's PC it will work without changing the database path.

    • @Taarnafeather
      @Taarnafeather 10 років тому

      I have the same question. And on top of that, what if I want to make it work in linux and windows? How should I name my path with slashes?

    • @areg7182
      @areg7182 9 років тому +2

      Actually, the working directory as the folder of the main class. You can drop your DataBase into the Project folder and write as
      Connection connection=DriverManager.getConnection("jdbc:sqlite:UserDB.sqlite")
      (I recommend to do it this way because you don't have to include the database in your project manually) OR write as
      Connection connection=DriverManager.getConnection("jdbc:sqlite:..\\UserDB.sqlite").

    • @th8452
      @th8452 5 років тому

      @@areg7182 This worked great, thank you.

  • @mayurgupta1020
    @mayurgupta1020 8 років тому

    hello sir I have eclipse juno . After added all jar file as your"s direction it shows erroe like "file does not exit" in your project but i had already added all the jar files it also shows in : company\jre system library folder.. can you resolve my problem

  • @jix2757
    @jix2757 8 років тому

    Anyway I can password protect the DB using JDBC?

  • @PawanKumar-dw4sg
    @PawanKumar-dw4sg 8 років тому

    unable to download jar file from above link :network error. please tell me another way i got stuck here .
    Thank you

  • @FaisalN93
    @FaisalN93 9 років тому

    would this work for creating an android application rather than windows?

    • @itay2828
      @itay2828 9 років тому

      I think it might work, but not 100% sure because the java android is running is very diffrent than the one most of the machines (or computers) you know are running, but i saw thats programing knowlege have a little tutorial on android and sqlite

  • @arsa5660
    @arsa5660 2 роки тому

    to all going through SQLException error i realized my mistake and its simply just using a semicolon after sqlite
    Before : Connection conn = DriverManager.getConnection("jdbc:sqlite;/Users/arsaradifan/Cars.sqbpro");
    AS YOU CAN SEE SEMICOLON AFTER ^^^
    After : Connection conn = DriverManager.getConnection("jdbc:sqlite:/Users/arsaradifan/Cars.sqbpro");
    FIXED
    i dont know if this is the problem for you guys however this helped for me hopefully it helped someone

  • @subhananjum5354
    @subhananjum5354 5 років тому

    how to give relative path in it?

  • @ashwinravichandran7047
    @ashwinravichandran7047 7 років тому +1

    even after adding all the jar files i get the same error

  • @mistertds
    @mistertds 8 років тому +2

    Working very good thanks , this is the link for repository bitbucket.org/xerial/sqlite-jdbc/downloads

  • @tayabrehman9021
    @tayabrehman9021 8 років тому

    i am getting excepton .. driver no suitable for jdbc:sqlite help me

  • @Individualist
    @Individualist 4 роки тому

    Hello. Thanks for the videos. I get this error: "No operations allowed after connection closed MYSQL"

    • @Individualist
      @Individualist 4 роки тому

      java.sql.SQLnontransientConnectionException:No operations allowed after connection closed

  • @riadh7953
    @riadh7953 6 років тому

    i didn't find JRE System library hepl plz

  • @anisurrahman2463
    @anisurrahman2463 7 років тому +1

    i also add all library. But i its show error.(Java,lang.ClassNotFoundException: org.sqlite.JDBC)....my database file path is correct but i have get ERROR ...anyone fix this ?

  • @muhammadsidibe2523
    @muhammadsidibe2523 9 років тому

    What should i do on mac when finding the location of the database

    • @LearnByExample
      @LearnByExample 8 років тому

      +Muhammad sidibe
      do you remember name of the database?
      type
      find ~ -name "nameofthedatabse"

  • @dermuschelschluerfer
    @dermuschelschluerfer 8 років тому +4

    also could have added external jars...

  • @abhishekhiremath730
    @abhishekhiremath730 3 роки тому

    Sqlite jdbc driver link is not working now

  • @technofreerun6932
    @technofreerun6932 9 років тому

    It took you 8 min to download it all.
    It would be better if you paused, found the one, and continiued the video!!!

  • @computerbolter4079
    @computerbolter4079 6 років тому

    What is the use of return(conn);

    • @patrickedwinmoran2966
      @patrickedwinmoran2966 6 років тому

      I think you mean "return conn;"
      Sometime a constructor is defined in such a way that it demands getting some feedback from the place earlier in the program that called the constructor. In this case the part of the program that asked for a connection to be established needs to know whether it got a connection, and if so, how is it to refer to that connection. Otherwise it needs a "return null," which tells it that it doesn't have anything to work with, so it can bail out however it is supposed to behave when it can't do its full job.

  • @technofreerun6932
    @technofreerun6932 9 років тому

    You could do the message like this:
    JOptionPane.showConfirmDialog(null, "Connection successful");

  • @AirKiter
    @AirKiter 9 років тому

    you only need to download the second java file

  • @arnemyggen
    @arnemyggen 9 років тому +1

    JDBC*

  • @anjofamini5697
    @anjofamini5697 9 років тому

    I've got an exception error said that my database path didn't exist even though I enter the right path of the database sqlite. Please help me. Thanks

    • @technofreerun6932
      @technofreerun6932 9 років тому

      Anjo Famini Did you put these "\\" or these: "//" you shall put the first ones. If it doesn't work then it is probably a bug with eclipse.
      P.S. Make sure that at the end you entered ".sqlite" or else it won't work

  • @TheKhan9191
    @TheKhan9191 8 років тому +1

    when i run this program so it show me this massage " java.sql.SQLException:path to "C:\Users\Public\EmplyeeData.sqlite:G:
    ew folder(2)copany\C:" does not exist"
    what should i do all my code is ok plz help me

    • @jerryprophete3367
      @jerryprophete3367 8 років тому

      +Khan Hamraz if you have not fixed yet. I think it shows this error because your path to your database is wrong. try to add this \\ instead of \ to separate you path, and add the name of your database , or you maybe you need to download the jar file and build the path for it.. if it does not fix start over and you ll see where you make your mistake..

    • @bhavanavenkat9582
      @bhavanavenkat9582 8 років тому

      when i run my program i get the same exception plz help me solve this error

    • @mmikhan
      @mmikhan 7 років тому

      You'll need to use absolute path. See the example here: ua-cam.com/video/l7IDevUUa3A/v-deo.html&lc=z132h3iastiyydyeo23ivheixtmqwjpsy

    • @zoltanhoffmann5947
      @zoltanhoffmann5947 7 років тому

      Hi, 1 year later, but here is the solution for this problem: stackoverflow.com/questions/39456728/java-sql-sqlexception-path-to-path-does-not-exist

    • @sherminfatma61
      @sherminfatma61 7 років тому

      I guess this answers looks most close to the solution but that's still not working in my case...anyone can help?

  • @xiaowei7606
    @xiaowei7606 8 років тому

    bro i have problem with this
    java.sql.SQLException: invalid database address: jdbc:sqlite:‪Java.db

    • @trideepdas6393
      @trideepdas6393 7 років тому

      Same error here..did u find any solution

  • @yeuduongtamhuong
    @yeuduongtamhuong 6 років тому

    xerial-sqlite-jdbc-8de652d3f54c...how i use this file?

  • @nagashivudu2090
    @nagashivudu2090 7 років тому

    Getting(opening error) can anyone help me

  • @AlecSzander
    @AlecSzander 9 років тому +1

    I got a message saying that it sais that the database adress is wrong, i copy pasted the path from the item i needed and i added the second "\" in the path, can you help me?
    : snag.gy/5SMyV.jpg :

    • @Ialiras
      @Ialiras 9 років тому

      same error
      help me................

    • @opalhutchinson5152
      @opalhutchinson5152 9 років тому

      Mag Ward you maybe put in the database name in twice towards the end of the code.

    • @AlecSzander
      @AlecSzander 9 років тому

      That is not the problem, now i don't have the code anymore since i had to work in netbeans and not eclipse and instead of database i used a text file, but i know for sure that it studied if i had some writing errors, and i didn't have any, it was something else

    • @itay2828
      @itay2828 9 років тому

      You wrote jdbc:sqlie and not jdbc:sqlite

    • @AlecSzander
      @AlecSzander 9 років тому

      Itay Almog OH MY GOD, i'm so dumb, and i couldn't even see it

  • @MerihYilmazer
    @MerihYilmazer 7 років тому

    not good..

  • @patrickedwinmoran2966
    @patrickedwinmoran2966 6 років тому

    The exact way given for writing sqliteConnection.java is not acceptable to my Eclipse Oxygen in 2018.
    I'm working through several fixes needed to update the original code. Meanwhile, here is something that works for me:
    import java.sql.*;
    import javax.swing.*;
    import java.sql.Connection;
    public class sqliteConnection {
    public static Connection dbConnector(){
    Connection conn = null;
    try {
    Class.forName("org.sqlite.JDBC");
    conn = DriverManager.getConnection("jdbc:sqlite:/Users/JohnPauLJones/EmployeeData.sqlite");
    JOptionPane.showMessageDialog(null, "Connection to the sqlite database successful.");
    return conn;
    }catch (Exception e)
    {
    JOptionPane.showMessageDialog(null, "Exception to sqliteConnection process: " + e);
    return null;
    }
    }
    }
    Note that I am using the Macintosh convenetions. Windows evidently requires the backslash, and the backslash means something to the compiler, so it has to be "escaped" by adding a second backslash to say, "I mean the following backslash to go through as it. Don't use it as a direction to the computer."

  • @MaximkoGamerUA
    @MaximkoGamerUA 9 років тому

    Your coding is totally horrible for computer resources. If you don't agree with me, imagine that you're coding GTA 5 for example. You gonna import directX 10, 10.1 and 11 because, in directX 11 there is no shader from directX 10.1 or directX 11 because in directX10 there isn't such shader. And it isn't so smart to import like java.sql.*. It is looks horrible for pc hardware too. Better experiment than doing this. BUT your videos are veeery helpful!

  • @decipherwithzaryab5106
    @decipherwithzaryab5106 6 років тому

    Speak a bit fast buddy....uh take irritating pauses ..
    Your speaking style
    Makes your videos annoying

  • @aafaqueanwarali3943
    @aafaqueanwarali3943 6 років тому

    "sqlite cant open unable to open the db file(out of memory)"
    i have seen this message on my scrn any solution? guide me plz

  • @ahsansyed4146
    @ahsansyed4146 7 років тому

    when i run my code i get this error :/
    "java SQLException:opening db 'D:\workSpace\employeeData.sqlite\employeeData.sqlite': the system cannot find the path specified"
    kindly help me out

    • @Ucciolo
      @Ucciolo 7 років тому +1

      D:\workSpace\employeeData.sqlite\employeeData.sqlite
      Why do you repeat employeeData.sqlite two times?
      Have you got a folder with the same name containing the database?

    • @ahsansyed4146
      @ahsansyed4146 7 років тому

      thanku for ur reply :)

    • @Ucciolo
      @Ucciolo 7 років тому

      :) Did you solved it?