Solved

Netbeans creating a desktop application connecting to SQL Server DB

Posted on 2011-09-21
5
391 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
  • 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TSQL previous 5 24
Add '#' to end of file 2 30
sql query questions 2 21
Executing SSIS with a Stored Procedure Permissions 12 22
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now