Solved

Netbeans creating a desktop application connecting to SQL Server DB

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how the fundamental information of how to create a table.

744 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

12 Experts available now in Live!

Get 1:1 Help Now