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 8118823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:36:54+00:00 2026-06-06T04:36:54+00:00

I am creating a REST Web Service using Java and Jersey API. The basic

  • 0

I am creating a REST Web Service using Java and Jersey API. The basic REST service works fine,but when I add in a DB connection it gives me a Class Not Found Exception and a SQL Exception – No driver found. I have included the ojdbc6.jar file in the Eclipse build path. Using the same code if I create a Java application it runs fine.
I have added my code below. Can some one plz suggest something.
EDIT: I included the jar file in the WEB-INF lib directory. But when I try to execute the code I get the following error: HTTP Status 405 – Method Not Allowed

public class Note {

    private int noteId;
    private String content;
    private Date createdDate;

    public Note() {}

    public Note(int noteId, String content, Date createdDate) {
        this.noteId = noteId;
        this.content = content;
        this.createdDate = createdDate;
    }

    public int getNoteId() {
        return noteId;
    }

    public void setNoteId(int noteId) {
        this.noteId = noteId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }
    @Override
    public String toString() {
        return "Note [content=" + content + ", createdDate=" + createdDate
                + ", noteId=" + noteId + "]";
    }
}

public class NoteDAO {

    DatabaseAccess data;
    Connection connection;

    public NoteDAO()
    {
        try {
            data = new DatabaseAccess();
            connect();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    private void connect() throws SQLException
    {
        try
        {
            data.connect();
            connection = data.connection;
        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }
    }

    public Note getNoteById(int id) 
    {
        PreparedStatement prepStmt = null;
        try {
            String cSQL = "SELECT * FROM NOTE WHERE NOTEID = 12 ";
            prepStmt = connection.prepareStatement(cSQL);
            prepStmt.setInt(1, id); 
            ResultSet result = prepStmt.executeQuery();
            Note note = new Note();
            while (result.next())
            {
                note.setNoteId(result.getInt(1));
                note.setContent(result.getString(2));
                note.setCreatedDate( (Date) new java.util.Date(result.getDate(3).getTime()));
            }
            return note;
        } catch (SQLException e) {
            e.printStackTrace();
            prepStmt = null;
            return null;
        }
    }




}
@Path("/notes")
public class Notes {

    @Context
    UriInfo uriInfo;
    @Context
    Request request;

    NoteDAO dao = new NoteDAO();





    @Path("{note}")
    @GET
    @Produces(MediaType.APPLICATION_XML)
    public Note getNote(
            @PathParam("note") String idStr) {
        int id = Integer.parseInt(idStr);

        Note note = dao.getNoteById(id);
        if(note==null)
            throw new RuntimeException("Get: Note with " + id +  " not found");
        return note;
    }


public class DatabaseAccess {

    Connection connection = null;

    public void connect() throws SQLException
    {
        String DRIVER = "oracle.jdbc.driver.OracleDriver";
        String URL = "jdbc:oracle:thin:@xx.xxx.xx.xxx:1521:XXXX";
        String UserName = "username";
        String Password = "password";
        try
        {
            Class.forName(DRIVER);
        }
        catch (ClassNotFoundException e)
        {
            e.printStackTrace();
        }
        try
        {
            connection = DriverManager.getConnection(URL,UserName,Password);
        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }
    }
    public void disconnect() throws SQLException
    {
        connection.close();
    }

}
  • 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-06-06T04:36:55+00:00Added an answer on June 6, 2026 at 4:36 am

    If you are using datasources that are managed by the application server, you need to put the ojdbc6.jar library inside the lib folder of your application server.

    On JBoss for example, it would be $JBOSS_HOME/server/default/lib.

    This is required, because in such case, the datasource is being build when the server starts and independently from your application, which means the server cannot use your application JARs.

    If, however, you are pooling the connections yourself, you need to make sure, that the ojdbc6.jar is inside the lib folder of your application WAR archive.

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

Sidebar

Related Questions

I'm creating REST service using ASP.NET Web API. How can I return 401 status
I have to call the web service using java script? e.g. I'm creating one
I'm creating a REST web service using spring and I need to implement login/logout
I am creating a REST Web service in C# and need to take a
We are creating ReST Web Services using ASP.NET and OpenRasta. Is there any tool
I am creating a REST web service that returns XML documents by serializing .NET
I am creating a web service which uses REST web services. The client side
I'm not a security expert by any means, but I favor creating REST-style web
Background: I am creating a REST api, that will require users to use only
I am creating a site for our customer service department to request password rest

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.