Search for data within a database table
Hi everyone :)
I'm trying to make it so that the user can search for a record by id #. So, i made an input dialogue thing so the user can enter a record #. Basically, i want the data to appear in their textboxes based on the record # inputted by the user. My attempt is shown below, and when I run it, I get this:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
Here's my code:
public JButton getSearch()
if (search==null)
search = new JButton("Search Database");
search.addActionListener
new ActionListener()
public void actionPerformed(ActionEvent ae)
try
String str_rec =
JOptionPane.showInputDialog(
getFrame(),"Enter Record No");
int recNo = 0;
try
recNo =
Integer.parseInt(str_rec);
catch (NumberFormatException nfe)
return;
String select = "SELECT studId,studFirstName,studLastName " +
"FROM Students " +
"WHERE studId = '" + recNo + "' ";
Statement statement = getConnector().getConnection().createStatement();
ResultSet result = statement.executeQuery(select);
System.out.println(recNo);
getView().getId().setText(str_rec);
getView().getFirstName().setText(result.getString("studFirstName"));
getView().getLastName().setText(result.getString("studLastName"));
catch (Exception e)
e.printStackTrace();
return search;
}I hope I explained everything properly. If you could please help me, I'd very much appreciate it.
Thanks in advance! :)
- spidey
"WHERE studId = '" + recNo + "' ";Why are you putting quote marks around a number? What type of database column is studId? Probably a numeric type (not character), right? Quotes go around string/character stuff, not numeric stuff.
Similar Messages
-
Deletion of data within the database tables
The user is trying to clean up the 2014 data within the database tables. He is running a delete function which keeps causing the log files
to exceed their limit. The tables are large and he is unable to delete the data in one command due to available size and logging. What is the best way to approach this?
Thanks,Hi venkatesh1985,
According to your description, the user fails to delete data in tables due to the limited space of log file. Based on my research, this issue could occur when you use the delete statement(DELETE FROM ExampleTable) in a single transaction and consume all
available space on your transaction log disk.
To avoid this issue, you could use the two methods below to delete the data.
1. Use a loop combined with TOP and delete rows in smaller transactions as the following example. This method requires you to delete all the tables one by one.
SELECT 1
WHILE @@ROWCOUNT > 0
BEGIN
DELETE TOP (1000)
FROM LargeTable
END
For more information about the process, please refer to the article:
http://dbadiaries.com/how-to-delete-millions-of-rows-using-t-sql-with-reduced-impact
2. If you want to delete all the data from all tables in the specific database, you could script the entire database and all database objects. Then drop the database and recreate it using the script as the steps below.
a. In Object Explorer, expand the node for the instance containing the database to be scripted.
b. Point to Tasks, and then click Generate Scripts and click Next.
c. Select the option of 'Script the entire database and all database objects'.
d. Specify how scripts should be saved. You could save the script to a file or new query window. Click Next, then click ok.
e. Drop the database, and run the script in the query window to recreate it. For more information, please refer to the article:
http://msdn.microsoft.com/en-us/library/bb895179.aspx#Introduction
In addition, if possible, please increase the size of the log file or move the log file to a different disk with more disk space.
Regards,
Michelle Li -
Searching for documens within dates
I thought that my issue was a trivial one but I have not a way to resolve it.
I have three Doc libraries containing mainly PDFs.
I need to be able to search for files within two dates (based either on Created, Modified or a Custom Date that I defined in each library).
ThanksThis works for Created:
Created>12/11/2013 Created<12/15/2013
as does this (both are managed properties for the same field)
DocCreatedTm>12/11/2013 AND DocCreatedTm<12/15/2013
This works for Modified:
Write>12/11/2013 AND Write<12/15/2013
You can use LastModifiedTime, Write or FileWrite as the property name.
You can find a list of managed properties ("Manage Search Schema") in the Search admin pages of Central Admin or Office 365.
Note that AND, OR and NOT must be in upper case.
Mike Smith TechTrainingNotes.blogspot.com
my SP customization book -
Search for data in server based database.
I have a web page (http://gosolivitahomes.com) where I can enter a search for data in my server based database. If I enter a value less than $100,000 in Min Price I get no response. For values >= $100,000 I get the correct response. Why? Please help.
Yesterday I got no properties under $100,000.
To day I tried again and the first time I got 2 results, but when I went back and repeated the same thing, I got no result.
Then, like John Waller suggested, I cleared my cache and the 2 result were back.
Perhaps your problem is a template or other cms cache issue. I don't know very much about it, but when I had a login problem I had to disable user cache i the cms (Joomla).
I hope you will solve the problem -
I want to populate data from two database tables into a BAM report. I have created two data objects for the tables and want to create 3rd data object so that it can take the data from the other data objects automatically. Is there any such facility within BAM?
Hi
1. I am not sure if you have option to combine multiple DataObjects like that.
2. For your scenario, on Database side itself, I would recommend Create a VIEW that joins these 2 Tables and pull the required Columns and add required conditions. Verify the VIEW has all the rows expected.
3. Then create DataObject for this View. Once you have DataObject, create the Report.
Thanks
Ravi Jegga -
How to input data in a database table without knowing in advance table and column configurations
Hi,
I have a problem using LabVIEW for input data (manually) in a SQL database. I have about 40 tables in the database, each of them is related to a specific engine component. I need to create a user interface (maybe visualizing the table with a table control) where the users can insert data in the database table fields. Could someone give me some suggestion on how to do it?
Using the DB tools insert data.vi I need to know in advance the column configuration of the table, but in my database each table has its own structure! So do I have to create 40 different masks, one for every different table?
Thanks in advance.
MichelaI have not actually used the LV SQL Toolkit, but I will try and offer high level ideas :-)
when you have retrieved the construction data for a table, you should be able to use array and cluster indexing to aquire the names of the fieds, enough to create a labelled table on the LV Front panel.
After completing a new entry you can INSERT the entry into the database using the same data.
Is the SQL toolkit an additional purchase, or included in newer versions as standard? If you post a sample of the cluster/array that you retrieve, I could give you a sample VI to give you some pointers in creating the User Interface table
- Cheers, Ed -
Updating data in the database table
Can any help me in the code for updating data in the database table.
Regards,
RahulHi Rahul,
A slightly longer procedure that i'm adding here...
1.) Create the component (i'm sure you have this covered)
2.) Next on the button click that updates the database - add an action.
3.) double click the action so that you are taken to the methods section of the view.
4.) next you need to add the code that is required the update the database - this will be in the form of the above two posts.
5.) compile and test the application
Let me know in case you need further information on how to do this with a function module or something.
Thanks. -
How to fetch data from single database table using 2 internal tables.
Hi friends,
i am a new user of ABAP and also SDN.
i need a help.
i want to fetch data from one database table based on primary keys of 2 internal tables. how to put in where clause.
Thanks in advance.hii
refer to following code ..i hope it will help you
SELECT matnr " Material Number
FROM mara
INTO TABLE i_mara
WHERE matnr IN s_matnr.
IF i_mara[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
prctr " Profit Center
FROM marc
INTO TABLE i_marc
FOR ALL ENTRIES IN i_mara
WHERE matnr = i_mara-matnr
AND werks IN s_werks.
ENDIF. " IF i_mara[] IS NOT INITIAL
i_output = i_marc.
IF i_marc[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
lgort " Storage Location
FROM mard
INTO TABLE i_mard
FOR ALL ENTRIES IN i_marc
WHERE matnr EQ i_marc-matnr
AND werks EQ i_marc-werks
AND lgort IN s_lgort.
ENDIF. " IF i_mara[] IS NOT INITIAL
regards
twinkal -
Search for tablenames in the database using native sql query script
How do i search for the names of the tables in the database using select statement? I do not know the names of the tables but I know the name of the database and i do not have the sys priviliges.
thanks
SSSELECT owner, table_name
FROM all_tables; -
Can I restore the deleted statistical data from the database tables?
Hi all,
I have deleted the statistical data from the database tables like(Ex: RSDDSTAT, RSDDSTATWHM,..) by mistake through RSA1> Tools> BW Statistics for Infoproviders--> Delete.
Is there any way to restore the deleted data back? Thanks in advance.Now I'm really confused-
Your first post said
"<b>I have deleted the statistical data from the database tables like(Ex: RSDDSTAT, RSDDSTATWHM</b>,..) by mistake through RSA1> Tools> BW Statistics for Infoproviders--> Delete."
but your last respsonse said
"I have deleted the BW Statistics data, <b>not the actual data in RSDDSTAT tables</b> through
RSA1 -> Tools -> BW Statistics for InfoProviders -> clicked 'Delete' bin to delete data."
If you used the RSA1 -> Tools -> BW Statistics for InfoProviders -> clicked 'Delete' - <b>then you deleted the data from the RSDDSTAT tables</b>. This assumes you accepted the default date range that would have popped up after the clicking on the Delete button which specified to delete thru the current date. If this is what you did, the data is gone. Your only hope is be to recover from a DB backup.
The data in the RSDDSTAT tables is what is used to feed the BW Statistics cubes, generally on a daily basis. -
When / why use XML to store data instead of database table ?
Hi All,
I still not use XML much in applications and don't know much about its utilization.
I read here and there about storing data as XML instead of into database tables.
- could any body please tell me when / why use XML to store data instead of database table ?
e.g : store inventory per warehouse in XML format. ?
- What is the other cases or reasons of extracting database records into XML or vice versa ?
- is there any good pdf on this ?
Thank you for your help,
xtantoIt depends entirely what you want to accomplish with the 'XML in the database'. There are basically 3 independent methods: As CLOB, as XMLType views or as native XMLType 'columns'
Each method has advantages and disadvantages, especially in the performance vs purpose tradeoff.
The Oracled Press book "Oracle Database 10g XML & SQL Design, Build, & Manage XML Applications in Java, C, C++, & PL/SQL" is highly recommended for anyone interested in Oracle and XML. http://books.mcgraw-hill.com/getbook.php?isbn=0072229527&template=oraclepress -
Fetch data from different database tables
Hi...
How can i fetch data from different database tables and put it into a internal table and then display it??? Can provide simple short codes as i'm new to ABAP. Thanks.Hi,
Check this sample code..
TYPE-POOLS: slis.
DATA: BEGIN OF itab OCCURS 0,
vbeln TYPE vbeln,
expand,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0,
vbeln TYPE vbeln,
posnr TYPE posnr,
matnr TYPE matnr,
netpr TYPE netpr,
END OF itab1.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'POSNR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'POSNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'MATNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'NETPR'.
s_fieldcatalog-do_sum = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
DATA: s_layout TYPE slis_layout_alv.
s_layout-subtotals_text = 'SUBTOTAL TEXT'.
s_layout-key_hotspot = 'X'.
s_layout-expand_fieldname = 'EXPAND'.
SELECT vbeln UP TO 100 ROWS
FROM
vbak
INTO TABLE itab.
IF NOT itab[] IS INITIAL.
SELECT vbeln posnr matnr netpr
FROM vbap
INTO TABLE itab1
FOR ALL ENTRIES IN itab
WHERE vbeln = itab-vbeln.
ENDIF.
DATA: v_repid TYPE syrepid.
v_repid = sy-repid.
DATA: s_keyinfo TYPE slis_keyinfo_alv.
s_keyinfo-header01 = 'VBELN'.
s_keyinfo-item01 = 'VBELN'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
it_fieldcat = t_fieldcatalog
i_tabname_header = 'ITAB'
i_tabname_item = 'ITAB1'
is_keyinfo = s_keyinfo
TABLES
t_outtab_header = itab
t_outtab_item = itab1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks
Naren -
How to load text file data to Oracle Database table?
By using Oracle Forms, how to load text file data to Oracle Database table?
Metalink note 33247.1 explains how to use text_io as suggested by Robin to read the file into a Multi-Row block. However, that article was written for forms 4.5 and uses CREATE_RECORD in a loop. There was another article, 91513.1 describing the more elegant method of 'querying' the file into the block by transactional triggers. Unfortunately this more recent article has disappeared without trace and Oracle deny its existence. I know it existed as I have a printed copy in front of me, and very useful it is too.
-
Search for content within a PDF
Is it possible to search for content within a PDF across a mapped drive?
Yes. Use Edit>Advanced search. Choose All PDF Documents in and choose the mapped drive.
They have to be searchable PDF's of course... -
Create a data source and database tables using WSAD
Hi, guys:
the following is from a tutorial:
http://www-106.ibm.com/developerworks/websphere/techjournal/0306_wosnick/wosnick.html
"To create the data source and Cloudscape database tables automatically, right click on the HelloWorldServer in the Servers view, and select the Create tables and data sources menu item. A dialog will then display showing that the data source and database tables were created successfully (Figure 5)."
I am using WSAD 5.0 trial version. I cannot find Create tables and data sources menu item if I right click on the HelloWorldServer in the Servers view. I am wondering if this is because trial version does not have this feature?
regardsThis question is a little off topic but you may get a reply. Please note this forum is about Sun's J2EE SDK and its related technologies. You may have better luck posting your question to an IBM specific resource.
Maybe you are looking for
-
Why don't all my iTunes Library songs show up in my music folder
I have a lot of music in iTunes (16,000 plus songs) and they are stored on a LaCie external hard drive. Just recently I discovered that when I click on the file folder where all the music is stored, only files starting with A through B are listed. I
-
My iPod doesn't turn on anymore. Even when I plug it into the computer or a charger, nothing happens. What's wrong with my iPod?
-
How can I define the position of a SUD dialog in Diadem-AUT​O?
In the COD dialog-editor you can define the X- and Y-position of every dialog-window. In the SUD dialog-editor these options are not available. Is there any way to specify the position of a SUD dialog?
-
Selection of charateristic value by using a navigational attribute
Hello all. I'm working on BW 2004s with the integrated planning. I have this case: 0material has a navigational attribute - 0customer. I have a variable on the navigational attribute (ocustomer) which prompts the user to select a customer. on the nex
-
Tomcat cant start in windows xp 64bits
Dear members i have windows xp, processor and mainboard of 64 bits now C:\Documents and Settings\Administrator>java -version java version "1.5.0_12" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04) Java HotSpot(TM) 64-Bit Server