₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,711 members, 8,423,339 topics. Date: Tuesday, 09 June 2026 at 03:48 PM

Toggle theme

How Can I Search A Record In SQL Database? - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHow Can I Search A Record In SQL Database? (2130 Views)

1 Reply (Go Down)

How Can I Search A Record In SQL Database? by epospiky(op): 12:37pm On Jan 08, 2016
Hi. I am currently learning how to create database in java using SQL. I have successfully implemented commands like add new record, delete new record, update new record, next record, previous record, first record and last record. I am now looking forward to creating a search command in the database but i'm lost on how to go about it. The code is actually my concern. Please anyone with an idea should help me out.
Re: How Can I Search A Record In SQL Database? by Nobody:
www.java2s.com/Code/Java/Database-SQL-JDBC/JDBCselect.htm

For example if your are asked to find the male or female students use a query to search like

SELECT Male, female FROM Students

don't forget to know the format of your db and remember to use import SQL .

www.tutorialspoint.com/jdbc/jdbc-select-records.htm
Re: How Can I Search A Record In SQL Database? by Nobody: 1:35pm On Jan 08, 2016
Try searching for clues
Re: How Can I Search A Record In SQL Database? by epospiky(op): 9:12am On Jan 09, 2016
proxy20:
www.java2s.com/Code/Java/Database-SQL-JDBC/JDBCselect.htm

For example if your are asked to find the male or female students use a query to search like

SELECT Male, female FROM Students

don't forget to know the format of your db and remember to use import SQL .

www.tutorialspoint.com/jdbc/jdbc-select-records.htm
Thanks. From my understanding of what you posted, it seems i am to create a class with the "select" method and the output of the operation is going to be more than one record. I would rather it's just a single output with a particular key query. How about that?
Re: How Can I Search A Record In SQL Database? by Nobody:
Exactly you need create a class for the method

SELECT * FROM Male



SELECT * FROM ID1.Name

SELECT * FROM Faith WHERE
AGE =19


will select one output from you database .
The ID number or SN is very important in database management .

I think you need to connect your database through local host since you can't put it in in the package explorer by creating a directory and import the db . I don't know if that is possible .


put the zip file of your codes for me to download here on nairaland
Re: How Can I Search A Record In SQL Database? by epospiky(op): 6:29pm On Jan 09, 2016
ok i'll do just that. Just give me a moment.
Re: How Can I Search A Record In SQL Database? by epospiky(op): 6:46pm On Jan 09, 2016
proxy20:
Exactly you need create a class for the method

SELECT * FROM Male



SELECT * FROM ID1.Name

SELECT * FROM Faith WHERE
AGE =19


will select one output from you database .
The ID number or SN is very important in database management .

I think you need to connect your database through local host since you can't put it in in the package explorer by creating a directory and import the db . I don't know if that is possible .


put the zip file of your codes for me to download here on nairaland
Here it is.
Re: How Can I Search A Record In SQL Database? by Nobody: 6:50pm On Jan 09, 2016
Thanks bro
Re: How Can I Search A Record In SQL Database? by laykhorn(m): 9:07pm On Jan 09, 2016
epospiky:
Hi. I am currently learning how to create database in java using SQL. I have successfully implemented commands like add new record, delete new record, update new record, next record, previous record, first record and last record. I am now looking forward to creating a search command in the database but i'm lost on how to go about it. The code is actually my concern. Please anyone with an idea should help me out.
First, in the structure of your database while creating it, make an [b] id e.g. in the case of Facebook or username in the case of NL and most sites, you must have a parameter that has an index of PRIMARY which means the value of this input can only be taken on one table row and no other i.e. only one person can use such username or id.

You can query such column after selecting database and connecting to it with select queries like the below

"SELECT * FROM users WHERE id = ?", id

" SELECT * FROM users WHERE username = ?", username


NB: users was used as name of db
id and usernames after comma is how you'll retrieve your cars from db e.g. $_POST or $_REQUEST in PHP[/b]

Re: How Can I Search A Record In SQL Database? by Nobody: 10:25pm On Jan 09, 2016
I made some adjustments . I think you have to create a separate class like select.java .
Re: How Can I Search A Record In SQL Database? by epospiky(op): 10:26pm On Jan 09, 2016
laykhorn:
First, in the structure of your database while creating it, make an [b] id e.g. in the case of Facebook or username in the case of NL and most sites, you must have a parameter that has an index of PRIMARY which means the value of this input can only be taken on one table row and no other i.e. only one person can use such username or id.

You can query such column after selecting database and connecting to it with select queries like the below

"SELECT * FROM users WHERE id = ?", id

" SELECT * FROM users WHERE username = ?", username


NB: users was used as name of db
id and usernames after comma is how you'll retrieve your cars from db e.g. $_POST or $_REQUEST in PHP[/b]
I used the code in a button but it didn't work for me. It didn't even output anything. When i click on the search button it does nothing as if i never declared it.
Re: How Can I Search A Record In SQL Database? by epospiky(op): 10:30pm On Jan 09, 2016
proxy20:
I made some adjustments . I think you have to create a separate class like select.java .
Ok...waiting to see how it goes. Thanks dude.
Re: How Can I Search A Record In SQL Database? by Nobody: 10:34pm On Jan 09, 2016
Alright
Re: How Can I Search A Record In SQL Database? by laykhorn(m): 11:17pm On Jan 09, 2016
epospiky:
I used the code in a button but it didn't work for me. It didn't even output anything. When i click on the search button it does nothing as if i never declared it.
Can I have a look at your code? You might have a bug somewhere.



Paste on pastebin.co,m its better there.
Re: How Can I Search A Record In SQL Database? by epospiky(op): 10:55am On Jan 10, 2016
laykhorn:
Can I have a look at your code? You might have a bug somewhere.



Paste on pastebin.co,m its better there.
it's done. take a look at it [url="pastebin.com/rNrBD64K"]here[/url]
Re: How Can I Search A Record In SQL Database? by laykhorn(m): 3:29pm On Jan 10, 2016
epospiky:
it's done. take a look at it [url="pastebin.com/rNrBD64K"]here[/url]
busy right now. I'll do in a few hours... If I dont by 6 today, remind me. My Laptop and Tab arent available here
Re: How Can I Search A Record In SQL Database? by epospiky(op): 9:30pm On Jan 10, 2016
laykhorn:
busy right now. I'll do in a few hours... If I dont by 6 today, remind me. My Laptop and Tab arent available here
Just want to remind you...kind of.
Re: How Can I Search A Record In SQL Database? by laykhorn(m): 1:48pm On Jan 11, 2016
epospiky:
Just want to remind you...kind of.
Just Checked. Sorry, I don't do Java that much. JDBC isn't it for me
Re: How Can I Search A Record In SQL Database? by epospiky(op): 11:59pm On Jan 11, 2016
laykhorn:
Just Checked. Sorry, I don't do Java that much. JDBC isn't it for me
owkay. No qualms
1 Reply

Sql Database Error Gurus Pls Come InHelp!!! Login Failed For User in SQL ServerSQL Database Repair234

How Do I Disable The Cancel Button On The Top Corner Of Forms In C#?Start Learning Hacking For Free Today (new And Classic Fb Group)Flexbox Is Underrated. Here's The Skeleton Of An Image Gallery I Created.