Java prog#21.Advanced search a particular data in SQLite (MySql) Database in Netbeans java jtable
Vložit
- čas přidán 10. 05. 2012
- -----------------Online Courses to learn---------------------------
Java - bit.ly/2H6wqXk
C++ - bit.ly/2q8VWl1
AngularJS - bit.ly/2qebsLu
Python - bit.ly/2Eq0VSt
C- bit.ly/2HfZ6L8
Android - bit.ly/2qaRSAS
Linux - bit.ly/2IwOuqz
AWS Certified Solutions Architect - bit.ly/2JrGoAF
Modern React with Redux - bit.ly/2H6wDtA
MySQL - bit.ly/2qcF63Z
---------------------Follow--------------------------------------------
My Website - www.codebind.com
My Blog - goo.gl/Nd2pFn
My Facebook Page - goo.gl/eLp2cQ
Google+ - goo.gl/lvC5FX
Twitter - / programmingknow
Pinterest - goo.gl/kCInUp
Text Case Converter - goo.gl/pVpcwL
------------------------Stuff I use to make videos ------------------
Stuff I use to make videos
Windows notebook - amzn.to/2zcXPyF
Apple MacBook Pro - amzn.to/2BTJBZ7
Ubuntu notebook - amzn.to/2GE4giY
Desktop - amzn.to/2zct252
Microphone - amzn.to/2zcYbW1
notebook mouse - amzn.to/2BVs4Q3
-----------------Facebook Links ---------------------------------------
ProgrammingKnowledgeLear...
AndroidTutorialsForBegin...
Programmingknowledge
CppProgrammingLanguage
JavaTutorialsAndCode
SQLiteTutorial
UbuntuLinuxTutorials
EasyOnlineConverter
netbeans java tutorial
How to Advanced search a particular data in java netbeans table
MySQL and NetBeans Search Button
Java & MySQL Searching your database NetBeans
Retrieving database records using netbeans
iit Learn java netbeans
java tutorial netbeans
How to search a particular data in java netbeans table
netbeans search data from database
i think its better to use combobox for specific search then a search button.
Like this put this to search button or the releasekey in the video
if(combo.getSelectedItem().equals("ID")){
String sql="Select * FROM tbl_students where ID=?";
-
-
-
-
}
else if(combo.getSelectedItem().equals("LAST NAME")){
String sql="Select * FROM tbl_students where LastName=?";
-
-
-
-
}
i wish this come in handy.
Yes. That would also work. Just remember to add:
pst.setString(2, txt_search.getText());
pst.setString(3, txt_search.getText());
what happen when there are two two person with the same name or two person with same surname. I hope you understand my question...
yes sir , we would be glad if you could give a solution for this problem, my problem is that what if there are multiple people with same name and we don't no their emloyeeid(unique id ) either .
Thank you.
duus001 is right.Suppose the query below :
select * from EmployeeInfo where name = ? OR surname = ? OR employeeID = ?
Thus, our prepared Statement has to define 3 different parameters to search apparently in our database.
So, the only solution is to separate seach field's content into 3 distinct values;tto do this, pass 3 distinct parameters into pst:
pst.setString(1, searchJTextField.getText());
pst.setString(2, searchJTextField.getText());
pst.setString(3, searchJTextField.getText());
how to show the search result in Table
Hi, I am very happy to see you about java tutorial video, I want to ask is how to find data on Form1 when in enter will appear form2 to find the data and returns the search results to Form1 back, thank you for, quest, and if it could vedio toturialnya
what if user have many entry with same name?
just you can do this :
try {
String tmp = search.getText();
String sql = "select * from Employeeinfo where name=? or employeeid=?" ;
pst = con.prepareStatement(sql);
pst.setString(1, tmp);
pst.setString(2, tmp);
rs = pst.executeQuery();
.
..
.
.
.
}
+khaled saleh thank you
+Anna Galler welcome
thanks :)
just replace if with while in the code that you use to search name and surname
how you took that button group for those buttons ???
please reply..
Is there no shorter way to do this? like instead of:
"select * from Employeeinfo where name =?"
There could be:
"select * from Employeeinfo where name =? or employeeid =? or surname =?"
Is there any search using keyword??? Like I type in "pa" instand of "paul" and every record start with "pa" will list in JTabel and let user to select which record they want
st=con.prepareStatement("SELECT * FROM EmployeeInfo where Name=? or EmployeeID=? or Surname=? ");
st.setString(1, search.getText());
st.setString(2, search.getText());
st.setString(3, search.getText());
rs= st.executeQuery();
this ie enough
Doesnt work for me
& what if we have 2 or more similar data ?
How search data record in text field from directly below make a jtable1with already take data from database am dawood pls sir make tutrl
how to add autocomplete while searching.
How to put the searched data to jtable? Help please
+Tonberry I changed the KeyReleased method on a jTextFeild to filter the table for name only. I added this as a separate jTextFeild called txt_filter as it works differently to the search. It works more like the update_table method. Code is...
try{
String sql = "SELECT * FROM Employeeinfo WHERE name LIKE '" + txt_filter.getText() + "%'";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
Table_Employee.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
Hope this helps.
Hello .. im new in java. can you please make this program using gui? i cant understand this prog. coz its netbeans i dont know how to use netbeans. i want this prog in gui. please .. help me
Bad practice, why cloning code, what about 'OR' using in the query?
what is pst
what is the source code of this program??
what is pst? i seem to have problem with it. it doesnt recognize when i type it and gives error
Denz Patricio preparedstatement
how to show the search result in Table
+dutch man Hi, Did you find an answer to this? please share if you did. Thanks.
+dutch man I changed the KeyReleased method on a jTextFeild to filter the table for name only. I added this as a separate jTextFeild called txt_filter as it works differently to the search. It works more like the update_table method. Code is...
try{
String sql = "SELECT * FROM Employeeinfo WHERE name LIKE '" + txt_filter.getText() + "%'";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
Table_Employee.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
Hope this helps.
+therealslinky62 i dont understand about (DbUtils.resultSetToTableModel(rs)), can you explain to me ?
i used xampp mysql
+mikael 21 As I undersatand it DButils is a set of classes that help display the database table into the jTable. This is the command that shows the filtered results (rs) onto the jTable. Not best explanation but a google search will help you as well.