Solved

Netbeans creating a desktop application connecting to SQL Server DB

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

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.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

813 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

10 Experts available now in Live!

Get 1:1 Help Now