Design: Abstracting JDBC and datasource to SQL/DefaultTableModel [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
My back-end calls for a dynamic datasource and topology, and my front-end calls for a bunch of app coding that queries the RDBMS. My idea is to walk away from the JDBC API altogether, as it turns out, for any API the app coding couples itself to.
Here's the design idea... On queries, the app code passes in SQL, and receives DefaultTableModel as a result. On updates, the app code passes in SQL (even batches of it), and receives success/failure code (plus error message) as a result.
Would you couple all of your app code to class DefaultTableModel? Would there be a better class for generic, decoupled query result handling? (If I ever need metadata, I can subclass/encapsulate that in with the result) Are there examples out there of this already being done? I do not need more than the above for this application. I don't have extravagant RDBMS needs.
What standard non-JDBC options does the Java API have for holding the kind of data in a ResultSet? I am aware of AbstractTableModel and DefaultTableModel. In any event, it has to be smart enough to associate a class with each column in terms of datatype.

Related

Java Spring Security : is it good practice to separate the user data from the userdetails? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
First of all, this is what I mean by good practice :
code that is easy to maintain / fix
code that can be scaled
an architecture that is not going to cause security issues
With this out of the way, here is my problem :
I have a User class, currently it extends the UserDetails and has additional data attached to it not relevant to security ( for example purposes, let's say I added a user description / a profile page and data ). It works well and I can log in using it.
I, however, have seen tutorials and colleagues separate the data from the user details. They have a MyUserDetails class that only does the bare bones and encapsulates a User class that is used as a data container and nothing more.
Here is a good example of what I mean ( user related classes are roughly
in the middle )
Currently my implementation "works" but I am unsure if it's good practice and am unsure if I should separate the elements contained in my own user class as I don't know if it's any better.
Any help is most appreciated.
If by UserDetails you mean org.springframework.security.core.userdetails.UserDetails class - then it's definitely good idea to separate it from your application model. Single responsibility - one of key stones of good software architecture.

Java model best practices SQL - JSON -VIEW [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
While working on a Java web application I was wondering if my model layer was written as it should be. For instance, let's say we have a table USER in our SQL database which consists of 15 columns. Now, when we SELECT all of the columns with SQL we map it to a Java class, serialize via JSON and send it via network to some View and show it on screen.
In a second scenario, we want to select only 2 columns on screen so we do SELECT c1,c2 FROM USER. Thats where my question comes in... am I supposed to map those columns to a same Java model class? Or should i create a new mapper and class to fit it? Both of the approaches seem to have drawbacks, separate class for each query is more work, but it makes sure you always know what data it contains, rather than checking for nulls or working with optionals, also it prevents you from mapping columns you actually don't need.
What is your opinion? Thanks a lot!
Technically you could reuse the same User class for full 15-attribute as well as partial 2-attribute entity. But that will come with a price. Every time you'll see an instance of User class in the code your will have to think if it's the full entity or the partial? Which fields may or may not be null? This will make it much harder to reason about code.

Which implementation in JPA should be followed to optimize the login [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hey guys, I'm having a doubt about the implementation of class diagram above, confused between the Single_table strategy and the joined_table strategy, any help, any suggestion about the patterns followed in this case that are used to enhance the response time of the login process.
Any help will be appreciated.
Thank you guys in advance :).
If I got you right your concern is whether to us a table User with a flag of different Professor etc. tables. Well, I'd go for the single table. Actually there is not much difference in performance. In order to retrieve the professors from the user table you would need a WHERE clause while a native table has the records ready. The time difference in any case would be near to null as a RDBMS will handle WHERE clauses very effectively granted the DBA has set good indices. A single table is easier to maintain with respect to maintaining all the columns you need (but which your class diagram currently does not show).

Android SQL database organization [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am developing an Android native game, but I have problems with Data Storage.
For a better comprehension think it like as i am developing Clash of Clans, but with Native Andorid.
Now imagine I have to store all datas for Buildings, moneys, troups, ecc in my local phone DB.
I read some guides about SQLite for Android, but i don't really like it. It picks always a Cursor object and i have to create an "Helper" class for each table so I can convert the Cursor into the object I picked.
I want a library or anything else that allows you to do like windows phone c#:
SQLiteConnection conn = new SQLiteConnection(DBPath);
return conn.Query<TABLE_NAME>(SQL_QUERY);
//in this way i have a list of TABLE_NAME items without any casting or similar.
I learned SugarORM and it is really simple and intuitive, but it has no possibilities for ID usage(or at least really restricted) and a lot of other limitations.
And here is my question: is there a way to do it with SQLite without using cursor or with any other library, but still complete of all (or at least the most useful) functions?
check this link they explain the most five popular database and there characterstics

What exactly is a CRUD table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
What is a CRUD table and what is it used for? Is this just another name for a hash table?
I know that CRUD stands for create, retrieve, update, and delete. Are these not just the functions of a regular DB table?
Could someone give an example, maybe in Java?
There is no CRUD table. CRUD refers to operations on a table: create, retrieve, update, and delete. Those operations can be executed on any table. They are bundled together as they are the most basic operations.
A large number of applications that people write are 'crud'. They are simply creating entries in a database, reading them, updating them, and deleting them. Managing users, bug tracking, retail stock inventories... all mostly CRUD with various business logic wrapped around it from time to time.
There isn't such a thing as a crud table. Its just the most common type of application you will find out there, and a good bet what most programmers find themselves writing time and time again.
That the name crud is synonymous with 'dirt, filth, or waste, or something of poor quality' shows part of the distain that many people have for writing such applications. On this theme, some people will jokingly refer to "Create, Retrieve, Alter, Purge" as another form of the application.

Categories

Resources