Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4558516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:39:39+00:00 2026-05-21T17:39:39+00:00

I have a problem and i am new to this. I know how to

  • 0

I have a problem and i am new to this. I know how to create web methods to insert and delet from database but i don’t know how to get something from the database. I guess i have to pass the result of the query to a string and then return this string in order to get what i want. I have the following incomplete code.

@WebMethod(operationName = "getSomethingByID")
public String getSomethingByID(@WebParam(name = "idRocks")
String idRocks) {
    Dal dal = new Dal();
    ResultSet rs = dal.executeQuery("SELECT rocks FROM something WHERE idRocks ='" + idRocks+ "'");

        try
        {
            if(rs.next())
            {


            }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }

        return null;
}

How can i retrieve this information from database?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:39:40+00:00Added an answer on May 21, 2026 at 5:39 pm

    you will need something like:

    String query = "SELECT rocks FROM something WHERE idSomething='" + idSomething+ "'";
    
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    String url = "jdbc:mysql://localhost:3306";
    Connection conn = DriverManager.getConnection(url, "root", "root");
    Statement stmt = conn.createStatement();
    
    ResultSet rs;
    rs = stmt.executeQuery(query);
    
    String result = "";
    
    while (rs.next()) {
        //'col1' refers to the value in each row in a column called col1 in you table
        result += rs.getString("col1");
    }
    

    This just concatinates the values into one long string and you can then return that value.

    You will need to import a JDBC Jar if you are using this approach (assuming it is a MySQL db you are using.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm quite new to hibernate and have stumbled on this problem, which I can't
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I do not have problem as such but I am quite new to Ruby.
I have problem with Qt::Tool flag. When I create new widget with Qt::Tool flag
I want to create gallery application which would get thumbnails and metadata from web
I have new problem. My code: .method public static void Main() cil managed {
I'm new in codeigniter I have problem I use my OS X Lion, and
I have problem on my blog: http://osify.com while processing add new post with above
I am new on iphone development and I have problem with CoreData. I hardly
I'm quite new here. I have a problem with the new iOS 5.1 slide-in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.