How to sort data from database and display in combobox in required order
Hi evrybody, it makes me sick i need to get data form database and fill combobox in required order (last item added to database - last firstName) actualy i already did that, but i'm useing DefaultComboBoxModel and all records are sorted in alphabetical order. Thanks very much for any help
The items in the JComboBox are displayed in the order in which you add them to the combo box. Use an order by clause in your SQL statement.
Don't [url http://forum.java.sun.com/thread.jsp?forum=54&thread=516608]crosspost.
Similar Messages
-
Dynamically fetch data from database and display it in the report
Hi,
We have a requirement in developing a report which needs us to dynamically fetch data from the database and display it in the report.
We have a column called WORKER in the report.
For each worker there is a measure(PSA) associated with it.
In the report we have to display both the WORKER and the PSA column.
What we want is, when we display the list of the workers, the corresponding workerid_id of the worker will be passed and the value of his PSA will be fetched from the database and displayed in the report.
Or anything similar to this.
We also have drill applied on this WORKER column. So after any drill up or drill down also the value for PSA should change.
Is there any way of doing this?
Please help if possible.
Thanks,hi,
data : count type i value 0.
data : Begin of itab occurs 0 ,
plan_version like hrhap-plan_version,
APPRAISAL_ID like hrhap-APPRAISAL_ID,
AP_START_DATE like hrhap-AP_START_DATE,
AP_END_DATE like hrhap-AP_END_DATE,
AP_STATUS like hrhap-AP_STATUS,
AP_STATUS_SUB like hrhap-AP_STATUS_SUB,
OBJ_DATE_SET like hrhap-OBJ_DATE_SET,
REVIEW_DATE_SET like hrhap-REVIEW_DATE_SET,
AP_DATE_SET like hrhap-AP_DATE_SET,
AP_DATE_EARLIEST like hrhap-AP_DATE_EARLIEST,
AP_DATE_LATEST like hrhap-AP_DATE_LATEST,
CHANGE_DATE like hrhap-CHANGE_DATE,
CHANGE_TIME like hrhap-CHANGE_TIME,
CHANGE_USER like hrhap-CHANGE_USER,
end of itab.
<b>select * from hrhap into corresponding fields of table itab.</b>
loop at itab.
write :/ itab-plan_version under 'plan_version',
itab-appraisal_id under 'Appraisal Id',
itab-AP_START_DATE under 'Start Date',
itab-AP_END_DATE under 'End date',
itab-AP_STATUS under 'Status',
itab-AP_STATUS_SUB under 'Substatus',
itab-OBJ_DATE_SET under 'Objective setting date',
itab-REVIEW_DATE_SET under 'Review date set',
itab-AP_DATE_SET under 'appraisal date',
itab-AP_DATE_EARLIEST under 'Earliest appraisal date',
itab-AP_DATE_LATEST under 'Latest Appraisal date',
itab-CHANGE_DATE under 'Change Date',
itab-CHANGE_TIME under 'change time',
itab-CHANGE_user under 'change user'.
count = count + 1.
endloop.
write : 'No of records' ,count.
rgds
anver
if hlped mark points. -
How to query data from database and store it into Managed Bean ?
Hi all,
In our application we have requirement to store information within Managed Bean to be accessed by ADF pages.
The information is stored in database tables.
The question is :
What is the efficient / recommended way to do that ?
I do not use apps module to query the data because the information is required in View layer not the model layer
Thank you for your help,
xtantoXtanto,
if the information is stored in the database then the question is if there is a database connect open already. If yes, then why not using this connection to query for the data you want to access and store. Alternatively you can directly open a JDBC connection in a managed bean or access an EJB session bean. However, this comes with the price of an extra database connection.
Make sure the managed bean is in session scope if you want to share the information without re-fetching it
Frank -
How to fetch data from Database using SUP MBOs
I'm learning to develop blackberry apps using SUP.I am new to both blackberry api and SUP.
I need to make a login page for a Student and then validate the username and password entered using data from a database.
I need to check the database for the username and password entered. What should be my next step? How do i get this data from the database. Using findAll() method is not working . Do i need to connect to SCC or unwired server first. If yes , then someone please provide a sample code for it.Hi!, I see your code and I see that you have a fee errors, try to use this:
import java.text.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.OutputStream;
* NOTE: You must put the try-catch and your sql code into the get method
/** Servlet program to take fetchdata from database and display that on the broswer*/
public class Fetchdata
extends HttpServlet {
String query = new String();
String uid = "ashvini";
String pwd = "******";
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, Exception {
try {
Connection con = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Testing";
con = DriverManager.getConnection(url, uid, pwd);
Statement s = con.createStatement();
query = "select * from gowri.msllst1";
ResultSet rs = s.executeQuery(query);
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<HTML>" + "<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" +
"<table>" + " <th>ITEM Code</th>");
while (rs.next()) {
out.println("<tr><td>" + rs.getString(1).trim() + "</td></tr>");//I change </tr></td> for </td></tr>
} //end of while
out.println("</table></BODY></HTML>");
catch (Exception e) {
System.out.println(e);
} //end of doGet method
}I hope this help you :) -
How to retrieve datas from database to dropdown list in jsp
hai.
please tell me how to retrieve a perticular field list from database to a drop down list using jsp. i am new to jsp. i am doing employee management system. in that i need to edit employee's details as like.
so that i want to display employee id's in a drop down list. i want to retrieve from database and display.
please help me in this .
advance thanks.Hello friendz,
If tht is the i wud suggest if guyz can go wid AJAX...
try to make use of xmlHttp Object and generate a new dependent drop down by using a property from a bean->servlet->VIEW(FORM)
else save the form state in a session and then refersh it. once all in again.
i had a similar problem which i solved in the following way
Hi friend,
I had a similar situation and i tried to solve it by using XmlHttpRequest Object(used in AJAX).
U can checkout the below example just for further reference delete
UserForm.jsp:
==========
<head>
<script>
var xmlHttp
function showState(str)
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
alert ("Browser does not support HTTP Request")
return
var url="getState.jsp"
url=url+"?count="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChange
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
function stateChange()
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("state").innerHTML=xmlHttp.responseText
</head>
<body>
<select name='country' onchange="showState(this.value)">
<option value='india>india</option>
</select>
<br>
<div id='state'>
<select name='state' >
<option value='-1'>pickone</option>
</select>
</div>
</body>
getState.jsp
============
<%@page language="java" import ="java.util.Hashtable" import ="java.util.Set" %>
<%
String country=request.getParameter("count");
response.setContentType("text/html");
response.setHeader("Cache-Control","no-cache");
try{
Hashtable ht = (Hashtable)session.getAttribute("<ATTRIBUTE_NAME>");
String buffer="<select name='state'><option value='-1'>Pick One</option>";
Set s=ht.keySet();
Object keys[]=s.toArray();
int size=keys.length;
for(int i=0; i < size;i++){
buffer=buffer+"<option value='"+ht.get(keys).toString()+"'>"+ht.get(keys).toString()+"</option>";
buffer=buffer+"</select>";
response.getWriter().println(buffer);
catch(Exception exp){
response.getWriter().println(exp);
%> -
How to retrive data from database views or projection views
how to retrive data from database views or projection views
Hi chintam,
1. Very simple
2. Just like normal select statement.
3. Select * from VIEWNAME.
4. (Instead of the tablename, we just have to give the viewname)
regards,
amit m. -
[webdynpro] How to get the data from database and store in Excel sheet
Hi All-
I am developing an application in Webdynpro and I need to provide a URL ( link ) which if clicked , need to collect the data from Database ( SQL Server ) and puts in an Excel Sheet corresponding fields and opens the sheet.....
Please look into this issue and help me out......
Regards,
CrisHi Cris,
Add-on to wat santosh has pointed to:
Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
(Or) If you have implemented your logic to get Database records below Blog should guide you in opening an excel with ur records.
Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
Regards,
N. -
How to fetch data from database in javafx 2.2 table which is editable.
Dears!
I want to fetch data from database in javafx 2.2 tableformat with jdbc , which is also editable and i can add more records in this table also.
Can anybody help meI can vaguely recall some sort of JavaFX database connectivity feature, I'm not sure if it's valid anymore.The link is based on JavaFX Composer which only applied to NetBeans 6.9 and JavaFX 1.x (both of which are now dead techs).
There is a good chance you will have to write your own. There are several blogs describing other peoples' work. You could probably use them as a reference.Here is Narayan's basic [url http://blog.ngopal.com.np/2011/10/19/dyanmic-tableview-data-from-database/] tutorial for displaying data from a database in a TableView, you'll need to look elsewhere for the editing portion.
The [url http://docs.oracle.com/javafx/2/ui_controls/table-view.htm]JavaFX TableView tutorial gives info about how to handle edits in a TableView, but you will need to tie the updates back to the database yourself.
It is possible that [url http://www.javafxdata.org/]DataFX may provide some facilities to help support you. -
How to pull data from EJB and present them using Swing ?
Hi all,
I've written stateful session bean which connect to Oracle database, and now I must write stand alone client application using Swing.
The client app must present the data and then let users add,delete and edit data and it must be flexible enough to iterate through the records.
The swing components can be JTextField,JTable etc.
How to pull the data from EJB and present them to users with the most efficient network trip ?
Thanks in advance
SetyaThanks,
Since the whole app originally was client-server app and I want to make it more scalable, so I decide to separate business logic in the EJB but I also want to keep the performance and the userfriendliness of the original user interface, and I want to continue using Swing as the original user interface does.
I've read about using Rowset and I need some opinions about this from you guys who already have some experience with it.
Any suggestions would be greatly appreciated.
Thanks
Setya -
How to extract data from database to XSLT?
I want to generate a report by XSLT, but the data is extracted from the database. I will use Access/SQL server for my database. Can i write SQL in XSLT to extract data from database? Have any sample code or reference website to show how it work?
THXfor example: "SELECT code, name FROM TABLE FOR XML RAW"
String xml = null;
if(rs.next()){
xml = rs.getString(1);
}You will get xml string something like this:
<row empID="1234"/><row empID="1235"/>
You can construct a DOM using this xml data and operate on it.
However you may explore more on resulting xml format.
A different SQL Query (rather than using XML RAW) may give output in a more desired format. -
How to retrieve data from database to the structure(complicated)
Hello everyone:
I want to retrieve data from database to the structure. but the structure defined like this below:
TOLERANZOB LIKE QAMV-TOLERANZOB
TOLERANZOB1 LIKE QAMV-TOLERANZOB
so how can I retrieve the data from the database ? make sure that the two fields contain data both.
Thanks in advance .
Regards
NickHi Nick,
To retreive data for TOLERANZOB from QAMV,
If you know the key fields then use
SELECT SINGLE TOLERANZOB FROM QAMV INTO TOLERANZOB WHERE keyfields.
else, you can use
SELECT TOLERANZOB FROM QAMV UPTO ONE ROWS INTO TOLERANZOB WHERE....
Once you retreive the data using the select query, you can check if it is initial and if not move the data from TOLERANZOB to TOLERANZOB1.
<b>Reward points for helpful answers.</b>
Best Regards,
Ram. -
Help , How to get data from database using recordset with UI API
I want to get a data from database
when I want to create recordset i notice that UI API didn't has record set
so I created recordset using DI API (SAPbobscom.recordset and SAPbobscom.company)
======================================================
Dim oCompanyUI As SAPbouiCOM.Company <<UI API
Dim oRecSet As New SAPbobsCOM.Recordset << DI API
Dim oCompanyDI As New SAPbobsCOM.Company << DI API
'=====================================================
oCompanyDI.Connect
Set oRecSet = oCompanyDI.GetBusinessObject(BoRecordset)
oRecSet.DoQuery ("SELECT T0.CardCode, T0.CardName FROM OCRD T0")
SBO_Application.MessageBox oRecSet.Fields.Item(1).Value
======================================================
but I got an error it said "you are not connected to company"
I'm really don't have an idea about how to get a data from using UI API (exp I want to get a date or costumer code)
can someone help me please, I really need it
Thanksyou need a single sign on
Dim oDICompany As SAPbobsCOM.Company
Dim sCookie As String
Dim sConnStr As String
Dim ret As Integer
oDICompany = New SAPbobsCOM.Company
sCookie = oDICompany.GetContextCookie
sConnStr = SBO_Application.Company.GetConnectionContext(sCookie)
If oDICompany.Connected Then
oDICompany.Disconnect()
End If
ret = oDICompany.SetSboLoginContext(sConnStr)
If Not ret = 0 Then
SBO_Application.MessageBox("set Login Context failed!")
Exit Sub
End If
ret = oDICompany.Connect()
If Not ret = 0 Then
SBO_Application.MessageBox("Company Connect failed!")
End If -
How to put datas from database in html�s forms?
Does anyone have any idea how to put datas from the database using JSP???
One option: put your data into a JavaBean and then put that into the session. You can then access it from your JSP. You can access the properties of the bean using the basic JSP scripting elements, or if you want to get fancy, both JSTL and Struts have a bunch of custom tags for working with JavaBeans.
-
How to put data from database into array
I need to answer hot to put data from database directly into array.
I tried like the code below but the error message said: java.lang.ArrayIndexOutOfBoundsException: 0, and it points to this line: numbers [row][0]= rs.getString("ID");
Hope you can help.
ResultSet rs = stmt.executeQuery(query);
int row=0;
String [] [] numbers=new String [row][10];
// output resultset
while ( rs.next() )
numbers [row][0]= rs.getString("ID");
numbers [row][1]= rs.getString("name");
row++;
// close resultset
rs.close();
thanks,DeviThe exception is been thrown simply because you assigned '0' to the 'row' variable, indicating a zero length of the array. In fact you should assign the row count to it.
After all, don't do that. Make use of the Collection framework and map the ResultSet to a Collection of DTO's.
List<User> users = new ArrayList<User>();
while (resultSet.next()) {
User user = new User();
user.setID(resultSet.getString("ID"));
user.setName(resultSet.getString("name"));
users.add(user);
} -
How to Extract Data from SAP and Load it into Essbase
Hi All,
Can you recommend some ways to extract data from SAP and load it into Essbase?. I have no knowledge about SAP, not sure how I can perform this task. Can I use ODI for this job?
Thankshi,
Not sure if this helps but give a try
you can create connection from EAS to SAP .. using a plug-in .. if you have access to oracle Support go for [ID 968961.1]
or
below are steps
1. In EASPATH\console, open components.xml in a text editor.
2. Under <PluginList>, enter <Plugin archiveName="SAP" packageName="com.essbase.eas.sap.ui"/> before the closing </PlugIn> tag.
3. Save and close the file.
4. In EASPATH\console\bin, open admincon.lax in a text editor.
5. Search for lax.class.path= and append ;..\lib\sap_client.jar;..\lib \sap_common.jar to the entry. Save and close the file.
6. In EASPATH\server\bin, open adminsvr.lax in a text editor.
7. Search for lax.nl.java.option.additional, and append -DRFC_INI=EASPATH\server\saprfc.ini. Save and close the file.
8. Create a new environment variable, RFC_INI, with a value of EASPATH\server\saprfc.ini
9. Copy librfc.dll andsapjcorfc.dll to EASPATH\server\bin. You may need to obtain these files from SAP.
let me know if it works :)
Maybe you are looking for
-
How can I get rid of the personal domain that is seen _in iWeb_ at publish settings page beside my MobileMe account. MoblieMe account: (www.attilarieger.com) On my MobileMe settings page (online) there is no personal domain set before - as seen, so I
-
ITunes Music store 'reviews' are not INTERNATIONAL
Can anyone tell me why reviews for albums or podcasts are only shown in the country that that review was written in? Especially PODCASTS, which are globally or universally accessable, if you are set to a specific country, you can only see reviews wri
-
Hello Javaers, I've a question for you regarding JTable edits - hoping to save some google time. I've a JTable that currently accepts edits by careful overriding of the standard methods, isCellEditable, and by specifying ((DefaultCellEditor)table.get
-
Device enrolment and push notification certificates weirdness
Really hope someone can help me with this one. After a fierce fight with my server I decided to do a clean install to make sure everything is in it's intended place and state. Besides many, many other issues (suddenly disappearing of Open Directory,
-
Can I select nonconsecutive pages in the Firefox dialog box?
The only options I see are print all or print a range. Let's saycI want to print pages 2,4,6-7 and 9. Is there a way to do that without having to select print several times?