Readiing in Db table and putting data into javascript select.

I need to hit a db and read in the contents of a specific table and put it (multiple data) in a select for that page. Any help appreciate!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In a JSP , For a table from an access db to be dispayed within <td></td> in ur html
My DSN is sample

<td> My Database Select
<!--connecting to database -->
                        <%@ page import="java.sql.*,*, java.util.*" %>
                            catch(Exception e){

                                  Connection connect=DriverManager.getConnection("jdbc:odbc:sample");
                                  Statement stmt=connect.createStatement();
                                  ResultSet result=stmt.executeQuery("select * from testTable"); %>

                       <select name="test">
                          <option value=" "></option>
                          String temp = " ";
                          { %>
                            <option >
                              temp=result.getString(1); //The value
                            <%= temp %> </option>
                      <%  }
                        connect.close(); %>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
what db are u using..

does this help ?

.. Cheers!
894359Author Commented:
Oracle 11i.. I will try it! I think it does help???
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

DO tell me if u need more help
894359Author Commented:
I will... thank you! :)
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
I did read data from Oracle, the connection pool i used is customized from DbConnectionBroker from , you can go and taka a look on its examples.

Find more examples at: and

Hope this helps

putting data into javascript select?
What do you mean by it
894359Author Commented:
I need to dynamically populate a select based on the previous form and the selections made on that form. So if for example some body picked USA as their country on form 1 on the next form (form2) I'm going to know that and load associated vendors (from db) for that country in to a select.
Did the previous posts solve your problem

894359Author Commented:
I haven't been able to try it yet due to major server problems! :( I'm still waiting!!!
try it
String countr;
if (countr==null)

<select name="country" size="1" id="<%=countr%>" style="width:140px;"tabindex="15">
            <option value="null" <%=(("null".toString().equals(countr))?"SELECTED":"")%>></option>
            <option value="1" <%=(("1".toString().equals(countr))?"SELECTED":"")%>>Belgium</option>
            <option value="2" <%=(("2".toString().equals(countr))?"SELECTED":"")%>>France</option>
            <option value="3" <%=(("3".toString().equals(countr))?"SELECTED":"")%>>United
      session.setAttribute("countr", countr);

in next page
countr=(String) session.getAttribute("countr");
use it in your sql query to get your resultset
hope you'll get it
Good luck
to put in a select box?
            conn = null;
            stmt = null;
            rset = null;
//depends which connexion u r using
            conn = DriverManager.getConnection(connStr,
                                                         "Scott", "tiger");
            stmt = conn.createStatement ();
            str = "SELECT CLIN_ID,CLIN_NAME FROM F_CLINIC where COUNTR_ID="+countr+" order by CLIN_NAME";
            rset = stmt.executeQuery(str);
          <select name="clinics_list" id="<%=clin%>"style="width:140px;" tabindex="14">
    while (
        String  clin_id = rset.getString(1);
        String  clin_name = rset.getString(2);
            <option value="<%=clin_id%>" <%=((clin_id.toString().equals(clin))?"SELECTED":"")%>><%=clin_name%></option>
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.