Solved

Netbeans creating a desktop application connecting to SQL Server DB

Posted on 2011-09-21
5
402 Views
Last Modified: 2012-05-12
Hi All,

I am a newbie to Netbeans my knowledge is quite basic.

Is it possible to create a table to update records in one DB Table also showing linked fields from other DB tables (which are not needing to be edited)
I also want to limit the amount of data shown using the equivalent of Select ...Where SQL query.

Is this possible?  
What is the best way to go about it?
Once you have confirmed this I will probably need some help implementing the solution!
Thanks a lot Experts
0
Comment
Question by:GracefBase
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36574817
Of course it is possible. Just use appropriate SQL statement selecting the fields which you need with the join if you need to link with another table
And you can forst select data - sshow them to user, accept changes in those field where they are possible,
and then update your DB table
 That is what you can do wiith JDBC - you just need correct driver, set up connection and devise SQL statements
This is the JDBC tutorial:
http://download.oracle.com/javase/tutorial/jdbc/
0
 

Author Comment

by:GracefBase
ID: 36579340
Hi For_Yan,
I actually have a desktop application which I made using the example in the tutorial 'Creating a custom desktop database application'
I've set up the connection to the SQL database using JDBC
and I have set up entities for the different tables, but I cannot figure out where to put the SQL query to link them all together.
When I followed the tutorial way of linking the tables in the main entity I kept getting errors as I replaced the integer type with the name of the other table (eg Chargetypes) as it said in the tutorial, but the errors say it is not a valid data type.
The table that shows the data at the moment has a query within the entity manager, and I have changed this to select the data from the main table (MRcharge) :
SELECT m FROM MrCharge m  WHERE m.mrID > 98573 ORDER BY m.mrID

However when I tried to add the join to the query I put eg:
SELECT m FROM MrCharge m, MrChargeView4 c  WHERE m.mrID > 98573 and c.MrChargeId = m.MrCharge ORDER BY m.mrID
but I get  errors - please can you help?  I think its something simple I'm missing?
0
 
LVL 1

Accepted Solution

by:
dileeph earned 250 total points
ID: 36588285
GracefBase,

Following the tutorial 'Creating a custom desktop database application' I believe you end up creating a JPA application. Are you aware of JPA? If not better learn that before you go through rest of the tutorial.  Essentially you have to write JPAQL queries rather than  SQL queries.
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 250 total points
ID: 36588379
I actually meant that you would rather go through JDBC tutorial
http://download.oracle.com/javase/tutorial/jdbc/ 
and at least start with the regular JDBC connection and SQL queries used within JDBC without
any JPA , entities, etc.
If you are really new to JDBC - as I understood from your question -  that's what I think is much apprroprite to do at least at first.

>Is it possible to create a table to update records in one DB Table also showing linked fields from other DB tables (which are not needing to be edited)
>I also want to limit the amount of data shown using the equivalent of Select ...Where SQL query.

>Is this possible?

You don't need any entity manager to do all that.
I'd rather start with plain JDBC


If you want to prossed with your path, well, post the errors, otherwise it is hardly possible
to think about any help to you.


 
0
 

Author Comment

by:GracefBase
ID: 36597591
OK thanks I will do that
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question