How to Get Data from Database to JTable in Java | Display MySQL Data into JTable

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

КОМЕНТАРІ •

  • @CSCORNERSunitaRai
    @CSCORNERSunitaRai  2 роки тому +4

    *_Got a question on the topic? Please share it in the comment section below and I will answer it for you._*

    • @iamnel3141
      @iamnel3141 Рік тому +1

      My codes didn't show anything 😢

    • @sadokfkaier7703
      @sadokfkaier7703 11 місяців тому

      Same think happened
      @@iamnel3141

  • @7_ajinkya
    @7_ajinkya 2 роки тому +6

    so far the only video that shows how to work with JTable and ScrollPane! Thank you so much!!

  • @preciousjumuad2958
    @preciousjumuad2958 2 роки тому +5

    Thank you ma'am! You just saved me from being stuck in a bug for a whole week. May you continue helping programmers, kudos!

  • @swanandlaghate5113
    @swanandlaghate5113 Рік тому +2

    Thanks a lot!!!! You have just cleared my 2.5 years long confussion!

  • @dannydevelops
    @dannydevelops Рік тому +1

    You deserve a medal for this. Thanks

  • @adramshapath4720
    @adramshapath4720 2 місяці тому

    Madam Excellent Performance with great detail

  • @SimplySuman
    @SimplySuman 2 роки тому +3

    So clearly explained ma'am 🙏

  • @IonianWinds
    @IonianWinds Рік тому +2

    you are an absolute lifesaver!! Thank you so much for sharing this!
    Wish you very happy holidays and an amazing new year! 💞

  • @definitelynotamexicanskele6913

    Thank you so much maam, you're a life saver!!!

  • @AbdessamadBelm
    @AbdessamadBelm Рік тому +2

    Great video , straight to the point.
    Thank you so much 👍

  • @bonissocool4638
    @bonissocool4638 2 роки тому +2

    Thank you so useful for my uni project!

  • @theamazingtutorial.9019
    @theamazingtutorial.9019 Рік тому

    Easy Explained. This video made my knowledge++. Thank you

  • @health.upgradedbyscience.7309
    @health.upgradedbyscience.7309 2 роки тому +2

    Great tutorial, thanks a lot! It´s of tremendous help for what I´m working on right now..

  • @LostMellodies
    @LostMellodies 2 роки тому +2

    Amazing video, very helpful.

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

      Glad you liked it👍 do explore my channel for more stuffs

  • @festussibanda5886
    @festussibanda5886 2 роки тому +1

    thank you so much, your video just helped me learn a new concept, keep up the good work

  • @harmonynamai3665
    @harmonynamai3665 2 роки тому +2

    Thanks a lot!! You saved my day.

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

      Glad it helped you👍Do explore my channel for more stuffs✅

  • @joelmarkjmj
    @joelmarkjmj Рік тому +2

    OMG Mam you saved me!

  • @devisri7645
    @devisri7645 2 роки тому +1

    Thank you for clear demo mam

  • @amitdlh
    @amitdlh Рік тому +3

    hello , please how can i solve this problem when I run i get : java.sql.SQLException: No value specified for parameter 1 ! thankyou .

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  Рік тому

      Check out no, of? And r u providing value for all these ? Or not

  • @robmanda007
    @robmanda007 2 роки тому +2

    Hi how are you, Thank you so much for the these tutorials. They are so helpful in my capstone project. May you please do lectures on how to create pie charts, bar graphs and line graphs fetching data from a database.

  • @manohartimothy5825
    @manohartimothy5825 2 роки тому +2

    Hallo Sunita , I must say that you are a very good teacher and you explained it very well....Thanking you.. I will deffinatly follow you with your more vidios....Manohar

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

      Thank you so for your kind words👍
      Your comments motivates me for creating videos. Stay connected✅ God bless you

  • @zeronetechlearner1546
    @zeronetechlearner1546 2 роки тому +1

    Thanks a million, Madam.

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +1

      You're welcome👍 Do explore my channel for such more contents

  • @jesty_internm-squared4867
    @jesty_internm-squared4867 2 роки тому +1

    Really Useful one....

  • @Programyourmindset
    @Programyourmindset 2 роки тому +1

    Very useful information thank you

  • @vijaykrishnagn
    @vijaykrishnagn 2 роки тому +2

    Thank you for the video 😊👍

  • @moalnaim
    @moalnaim Рік тому +1

    Thanks you really helped me with this

  • @ruchankayastha3273
    @ruchankayastha3273 2 роки тому +1

    thanks worked like a charm

  • @ranad2037
    @ranad2037 Рік тому +1

    Thanks a lot, you're the best

  • @MessiSwag10
    @MessiSwag10 Рік тому +2

    Thank you so much for the helpful video! I do have a question though. In your program, you knew the amount of columns before hand, so you were able to create the no, name, and makrs variables. Is there an alternate way to do this if you don't know what your column size will be?

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  Рік тому +1

      Yes you can use ResultSetMetaData interface.
      It's having method through which you can get column count.

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  Рік тому +1

      Refer my advanced java playlist. I have shown in one video

  • @mazedul1448
    @mazedul1448 Рік тому +1

    Outstanding

  • @SuhanasCreations
    @SuhanasCreations 2 роки тому +2

    Well explained 👍

  • @robert2001101
    @robert2001101 Рік тому +1

    Thank you for the helpful code tutorial. I'm having an issue with the column names not displaying properly though, they only show java.lang.String or java.lang.Integer. Could you help me with this please?

  • @SHEIMANALEKZANDAR
    @SHEIMANALEKZANDAR 2 роки тому +1

    Hi ma'am May i know how do view table without clicking a button! Like an Example when i run the program automatically The records from the database should show

  • @francescalabonte4346
    @francescalabonte4346 2 роки тому +1

    Great video

  • @hplat-vku
    @hplat-vku 11 місяців тому

    thank u very muchhhhhh, u helped me

  • @amithagolla6907
    @amithagolla6907 2 роки тому +1

    very useful video...

  • @hoangngochieu17
    @hoangngochieu17 Рік тому +1

    Could you tell me why I can't run JinternalFrame after extending it...

  • @developernilesh
    @developernilesh 2 роки тому +1

    Thanks a lot, v nice👍

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

      Glad you liked it👍Do explore my channel for more stuff

  • @sarthakgupta096
    @sarthakgupta096 Рік тому +1

    Thank you mam .

  • @S3Allinone
    @S3Allinone 2 роки тому +1

    Well explained

  • @arifhussain9676
    @arifhussain9676 2 роки тому +1

    THanks for the video, every time i press show button, It makes duplicate and show it on table. Can we do something so that no duplicate record shows on table

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

      Check addRow method.
      Did you wrote it twice?

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

      @@CSCORNERSunitaRai I wrote it one time but I press button twice or when you press button again and again, you get duplicate rows.

  • @JoeCee789
    @JoeCee789 2 роки тому +1

    So i'm using NetBeans and i seem to have a problem with the tblData read the comments and couldn't find a working solution how do get the tblData to work

  • @eshaesha9100
    @eshaesha9100 2 роки тому +1

    another question respected mam. How do i know which commands to use in the action Listener method. like you wrote so many command, database connectivity etc.. I mean is there any good guide for beginners?

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +1

      This question is wrt to what ?
      If u r asking related to jdbc then depending on buttons we hv to write code

    • @eshaesha9100
      @eshaesha9100 2 роки тому +1

      @@CSCORNERSunitaRai yes mam, it is mainly related to jdbc

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

      @@eshaesha9100 ok so when u click on add button write insert code, delete button write delete code and so on

  • @gladnn
    @gladnn Рік тому

    Would it be possible to make a custom column header instead metadata?

  • @marshyadav7885
    @marshyadav7885 2 роки тому +1

    model.setColumnIdentifiers() method is not displaying names of columns, no errors. Any solution?

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

      Did you placed ur jtable control properly?
      Follow the way I have shown. Delete and place again

  • @rajapandey773
    @rajapandey773 2 роки тому +1

    I am getting this issue...
    Unable to parse source.
    WindowBuilder was not able to parse source private javax.swing.JTextField textField;.

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +1

      Declare this variable in class not in constructor. Only Initialization in constructor

  • @pasha7748
    @pasha7748 2 роки тому +2

    Hi, could you please tell me, where i can find the Table control name (in your case tblData)? Because when i use tblData and declare it in class, there is an error, which says: cannot invoke javax.swing.jtable.getmodel() because tblData is null... I dont know how to fix this. Could you please help me?

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +1

      It's available in toolbox where u can see available controls just drag and drop

  • @Tacoburger22
    @Tacoburger22 2 роки тому +1

    Thank you so much!

  • @shaikhibnasazzad
    @shaikhibnasazzad 2 роки тому +1

    How to sort jtable data with the column?

  • @kartickmanna
    @kartickmanna Рік тому

    Hello, Mam. I want to display data in a table. The data are fetched from an excel.xlsx file stored in my local drive. How to do that preferably in IntellijIdea ?

  • @natarajanparameswaran6752
    @natarajanparameswaran6752 2 роки тому +2

    The code doesnt work if I want to retrieve from different tables

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

      It works u need just modify according to your table design

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

      @@CSCORNERSunitaRai suppose I am having 2 tables one with 4 cols and other with 5 then for the second table the 5th col will be empty in jtable as we are reading only 4 columns

  • @endmysuffering6847
    @endmysuffering6847 2 роки тому +1

    Hello, the first row ( the topmost ) is not showing up on the table how can I fix?

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +1

      Ok I'll check.. When I tried it was working

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

      @@CSCORNERSunitaRai I can send you my code because mine is alittle different from yours. Great vid btw!

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

      @@endmysuffering6847 ok u can share on my telegram @cscorner

    • @endmysuffering6847
      @endmysuffering6847 2 роки тому +1

      @@CSCORNERSunitaRai I was able to fix it I had to add the table to a jscrollpane. Thank you for responding still :)

  • @r_nikolov1
    @r_nikolov1 2 роки тому +1

    Thank you so much! =)

  • @eshaesha9100
    @eshaesha9100 2 роки тому +1

    respected mam, do we need any extension for the JFrame and the design view in Eclipse?

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +2

      If u want to use eclipse u need to add window builder

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +2

      Detailed tutorial on how to create swing in eclipse available on my channel under advanced java tutorial playlist

    • @eshaesha9100
      @eshaesha9100 2 роки тому +2

      @@CSCORNERSunitaRai yes mam, i just watched that tutorial. You are legend mam

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +1

      @@eshaesha9100 thank you so much dear👍please share

  • @jobinninan4481
    @jobinninan4481 Рік тому +1

    Thank you

  • @reizsax
    @reizsax 2 роки тому +1

    Please help, my ‘rs.getMetaData()’ is error. It suggests that I add cast to ‘ResultSetMetaData’ or change type of ‘rsmd’ to ‘ResultSetMetaData’. And even though I followed the suggestions, the table data still doesn’t show.

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +1

      Check your import. All jdbc related import should be from java.sql only

  • @saronaraphaelv.5878
    @saronaraphaelv.5878 2 роки тому +1

    Hello maam can you help me mine says no sutiable driver found

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

      Join my telegram and Please share screenshots of error. I will try to fix it

  • @GT-cv3xu
    @GT-cv3xu Рік тому +1

    thanks♥

  • @abusolo_3255
    @abusolo_3255 2 роки тому +1

    if i want to display only 1 row, how i can do that?

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

      You can use following method:
      jTable1.getModel().setValueAt(daya,row_index,col_index)

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

      @@CSCORNERSunitaRai can you please tell me where exactly to put this line ?

  • @akashbro3786
    @akashbro3786 9 місяців тому +1

    Mem addrow is not found. What i can do?

  • @jayanspaliwal5907
    @jayanspaliwal5907 Рік тому

    Actually, I have another function in a different package that does the fetching part using a class in another package, How can I display data using that function, here are the functions:
    public ArrayList findAllStudent() {
    ArrayList al=new ArrayList();
    conn=ConnectionPool.connectDB();
    String query="select * from student";
    try {
    Statement stmt=conn.createStatement();
    ResultSet rs=stmt.executeQuery(query);
    while(rs.next()) {
    StudentBean sb=new StudentBean();
    sb.setEnrollmentno(rs.getString("Enrollment"));
    sb.setName(rs.getString("Name"));
    sb.setAddress(rs.getString("Address"));
    sb.setBranch(rs.getString("Branch"));
    sb.setCollege(rs.getString("College"));
    sb.setSemester(rs.getInt("Semester"));
    sb.setGender(rs.getString("Gender"));
    sb.setSubject1(rs.getFloat("Subject1"));
    sb.setSubject2(rs.getFloat("Subject2"));
    sb.setSubject3(rs.getFloat("Subject3"));
    sb.setSubject4(rs.getFloat("Subject4"));
    sb.setGrade(rs.getString("Grade"));
    al.add(sb);
    }
    conn.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    return al;
    }
    The connectionpool class:
    public class ConnectionPool {
    static Connection conn;
    public static Connection connectDB(){
    try{
    // register driver
    Class.forName("com.mysql.cj.jdbc.Driver");
    // create the connection
    conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/studentdb","root","space");
    System.out.println("Database connected");
    } catch (ClassNotFoundException ex){
    ex.printStackTrace();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    return conn;
    }
    }

  • @abusolo_3255
    @abusolo_3255 2 роки тому +2

    7:52 you said "tblData" is your table name, but isn't your table name is "student"?

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

      I mean JTable control name.
      Thanks

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

      @@CSCORNERSunitaRai where can i find my JTable control name?

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

      @@CSCORNERSunitaRai it shows me error in this line (under the "tblData" exactly ) DefaultTableModel model=(DefaultTableModel) tblData.getModel();

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

      and one of the solutions the program tell me to create local variable to "tblData"

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

      never mind, it work fine now, thanks, i just replaced "tblData" to "table" and it worked haha

  • @abunaseribrahimimani
    @abunaseribrahimimani Рік тому

    Madam, please can I request for a demo on adding pagination on Jtable using eclips

  • @prasannaj384
    @prasannaj384 2 роки тому +1

    What is this eclipse ide version mam?
    Send the comment box that link

    • @prasannaj384
      @prasannaj384 2 роки тому +1

      Because that swing set that package not available mam in my ide

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

      Eclipse IDE for Java Developers - 2021-06

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

      If you want to get swing related stuffs you need to add WindowsBuilder.
      Refer this video :ua-cam.com/video/lctZ-NAWgDU/v-deo.html

  • @samoli02
    @samoli02 Рік тому +1

    How to do it with date ?

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

    how to get data from database to JTable in selected one column

  • @AshishKalgutkar
    @AshishKalgutkar Рік тому +1

    mam pura code dekha diya hota toh kya ho jaat ?

  • @leandrolara7450
    @leandrolara7450 2 роки тому +1

    Damaste or Thanks or Graciassssssssssss : ,}

  • @WitleRose
    @WitleRose Рік тому

    @Eduardoo sai do fake caraio

  • @prernaparwani3074
    @prernaparwani3074 5 місяців тому

    Java.awt . eventdispatchthread exception occurred

  • @babyph65
    @babyph65 Рік тому +1

    getModel() is not working on me

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  Рік тому

      Is it showing any error

    • @babyph65
      @babyph65 Рік тому +1

      @@CSCORNERSunitaRai my compiler has some error so I re- installed it, its fine now. Thanks ♥️

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  Рік тому

      @@babyph65 yes

  • @Nishantkumar-sr2bu
    @Nishantkumar-sr2bu 2 роки тому

    maam i got a problem with tbldata.getModel() its showing that it can't be resolved please help

    • @CSCORNERSunitaRai
      @CSCORNERSunitaRai  2 роки тому +1

      Declare tblData inside class. It's not able to find variable tblData