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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:27:06+00:00 2026-05-26T20:27:06+00:00

I’m trying to connect my application to my database. I does not give a

  • 0

I’m trying to connect my application to my database.
I does not give a error, its runs but it doesn’t fetch the info.
I’ve tried run tnsping from the command line to see if the listener is on, and it says that it’s ok.

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import java.io.*;
import javax.swing.*;

   public class Connector extends JFrame{
  public static void main(String[] args) throws SQLException, ClassNotFoundException 
 {
  Connection conn = null;
  //Statement stmt = null;
  try
  {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:dbserver", "scott","tiger");

  }
  catch(SQLException e)
  { JOptionPane.showMessageDialog(null,e.getMessage(), "Erro na COnexao!",JOptionPane.ERROR_MESSAGE);
  }
  catch(Exception e)
  { e.printStackTrace();
  }
  Statement stmt = conn.createStatement();
  ResultSet rset = stmt.executeQuery("SELECT * FROM AnimalM");
  System.out.println ("Nome Salario");
  if (rset.next()){
      System.out.println("Aloooo");
  int cod = rset.getInt(1);
  String nome = rset.getString(2);
  String nome_es = rset.getString(3);
  int id = rset.getInt(4);
  System.out.println (cod+" "+nome+" "+nome_es+" "+id);
  }
  rset.close(); //Close ResultSet
  stmt.close(); //Close Statement
   conn.close(); //Close Connection
   }
 }

It run until this instruction:

System.out.println (“Nome Salario”);

And then nothing else shows, the program stops.

Does anyone have an idea of what might be happening?

  • 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-26T20:27:06+00:00Added an answer on May 26, 2026 at 8:27 pm

    I’d recommend stepping through with the debugger in Eclipse to see what’s happening. Maybe the query returns no rows.

    One design note: This class mixes UI, connection acquisition, and database access into one. A better approach would be do separate these into different classes. Test one feature, put it aside, and let the other classes simply use the functionality that you just implemented and proved to be working fine.

    When you have one class doing too much you have no idea where the issue is when things go wrong.

    You aren’t closing your resources properly, either. Those should be wrapped in individual try/catch blocks.

    I’d put all the code into one try/catch finally block and close the resources at the end.

    I’d pass the connection into a data access object that would be responsible for acquiring the ResultSet and mapping it into objects or data structures.

    I would move all Swing out of the database layer. You can reuse it without Swing that way (e.g. if you switch to a web UI).

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string

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.