|
hey guys, i'm developing a grocery store java desktop app, and i don't know much about databases and which one is better : an embedded data base or MySql,Postgres...considering performance and storage.
thanks.
|
|
|
|
|
 Both databases (MySQL and PostgreSQL) are very well known and have almost the same functionality. As to performance - it's opinion based only Joking! The thruth is that the performance depends on many factors, such as:
Quote:
- You are not running with a transaction log (see "The transaction log"). A transaction log improves commit time for transactions that insert, update, or delete rows.
- You are using the 16-bit version of the Windows 3.x database engine. The 32-bit version has better performance, especially for larger databases.
- You are loading huge amounts of data into a database. See "Tuning bulk operations" for methods to improve performance.
- The database engine does not have an adequate amount of memory for caching database pages. See "The database engine" for command line options for controlling the cache size. Extra memory for your computer could improve database performance dramatically.
- Your hard disk is excessively fragmented. This becomes more important as your database increases in size. The DOS and Windows database engines cannot do direct (fast) reading and writing when the database file is very fragmented. There are several utilities available for DOS and Windows to defragment your hard disk. One of these should be run periodically. You could put the database on a DOS disk partition by itself to eliminate fragmentation problems.
- You are using a small page size for a large database. The page size is determined when the database is created by the initialization utility. You can find out the page size by using DBINFO. To change page size, you need to unload and reload your database.
- The database table design is not good. A bad database design can result in time-consuming queries to get information from the database. If indexes will not solve your performance problem, consider alternative database designs.
- Your hard disk is slow. A faster hard disk, a caching disk controller or a disk array can improve performance considerably.
- In a multiuser environment, your network performance is slow.
- You are fetching or inserting many rows of data. Consider using the multi-row operations.
See:
Comparison of relational database management systems - Wikipedia
DB-Engines Ranking - popularity ranking of database management systems
SQLite vs MySQL vs PostgreSQL: A Comparison Of Relational Database Management Systems | DigitalOcean
Factors affecting database performance
So, decision belongs to you...
Good luck!
modified 29-Apr-19 15:29pm.
|
|
|
|
|
|
You're very welcome.
Maciej Los
|
|
|
|
|
At one time, choosing a database platform required a few months of study, and a lot of meetings. Then the DBA's, etc.
Now it's like deciding what color socks to wear, and anyone can "do it".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
And everyone laughs at your choice of colours/patterns on the socks. 
|
|
|
|
|
My wife doesn't appreciate my choice of socks color, but she doesn't care about databases, so choosing adatabase is certainly less stressful!
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Embedded database if fine if you want to add small amount of data on regular basis. If you want to store huge data, then you should go for some custom database.
|
|
|
|
|
Well, I do not now what KIND of database you need ))
In case you need a NoSQL database then google "How to choose a (NoSQL) database system"
And if you need a SQL database the answer is simple - PostgreSQL
(And avoid MySQL like a plague)
And if you do not know about "NoSQL" then just use PostgreSQL ))
|
|
|
|
|
package convexHull1;
import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.swing.JFrame;
public class ConvexHull extends Canvas implements MouseListener{
private static int countA;
private static int countB;
private static ArrayList<Point> A = new ArrayList<Point>();
private static ArrayList<Point> B = new ArrayList<Point>();
private static Graphics gDC;
public ConvexHull() {
countA = 0;
countB = 0;
addMouseListener((MouseListener) this);
}
public static void main(String[] args) {
JFrame jf = new JFrame("Convex Hull");
ConvexHull convexHull = new ConvexHull();
jf.setSize(800, 600);
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.add(convexHull);
}
public void paint(Graphics gDC)
{
PrintWriter out;
String str = new String();
try {
out = new PrintWriter(new BufferedWriter(new FileWriter("hulloutput.txt",true)));
str = "";
for(int i = 0;i < countA;i++)
{
gDC.fillOval(A.get(i).getX()-5, A.get(i).getY()-5, 10, 10);
str += A.get(i).toString() + " ";
}
out.println("All points");
out.println(str);
out.println("Points on the hull");
str = "";
for(int i = 0;i < countB;i++)
{
gDC.drawLine(B.get(i).getX(),B.get(i).getY(), B.get((i+1)%countB).getX(),B.get((i+1)%countB).getY());
System.out.println(B.get(i).getX() + " "+ B.get(i).getY());
str += B.get(i).toString() + " ";
}
out.println(str);
System.out.println();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
int x = e.getX();
int y = e.getY();
Point point = new Point(x,y);
A.add(point);
countA++;
while(!B.isEmpty())
B.remove(B.get(0));
countB = B.size();
repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
}
}
How can I add JMenu to this and handle the events
|
|
|
|
|
|
import javax.swing.*;
class MenuExample
{
JMenu menu, submenu;
JMenuItem i1, i2, i3, i4, i5;
MenuExample(){
JFrame f= new JFrame("Menu and MenuItem Example");
JMenuBar mb=new JMenuBar();
menu=new JMenu("Menu");
submenu=new JMenu("Sub Menu");
i1=new JMenuItem("Item 1");
i2=new JMenuItem("Item 2");
i3=new JMenuItem("Item 3");
i4=new JMenuItem("Item 4");
i5=new JMenuItem("Item 5");
menu.add(i1); menu.add(i2); menu.add(i3);
submenu.add(i4); submenu.add(i5);
menu.add(submenu);
mb.add(menu);
f.setJMenuBar(mb);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
new MenuExample();
}}
Are you looking for java online courses? No need to worry, at E2E Training academy we provide java full stack development courses Full Stack Java Developer & Salesforce Admin Online Courses[^]
|
|
|
|
|
please i dont know how you could help me am working on my final year project and this is the topic my supervisor choose for me pls can i get some help on this or sources that could help? am so so confused will be happy if i could get a reply soon. thank in advance
|
|
|
|
|
|
<pre>g.drawString is not printing the correct value in Jpanel.
The program is few thousand lines long. So I am posting a snippet where the error occurs
String tmpStg=new String(Integer.toString(val3));
System.out.format("%d %d %s %s\n",indexOfBlock,indexOfBlock1,String.valueOf(indexOfBlock1),tmpStg);
g.drawString(String.valueOf(indexOfBlock1),thsXPosWithBorder+10,thsYPosWithBorder);
System.out.format("%d %d %d\n",indexOfBlock,indexOfBlock1,val3);
Output of this section of the code is
0 8 8 8
0 8 8
While the values in print statement are correct. The value printed on the jpanel using g.drawString
is not correct. The g.drawString method prints 0 in the graphics panel instead of 8. The value in indexOfBlock1
is 8 and value in indexOfBlock is 0. Value in val3 is also same as value in indexOfBlock1. But if
I print it through g.drawString then it shows value as 0.</pre>
|
|
|
|
|
Are you certain that no other code is overwriting the value? Use the debugger to see exactly what is occurring.
|
|
|
|
|
I give print statements before and after drawString command. the values printed are correct in the print statements. But the value is not correct in the drawstring statement that occurs between the print statement.
I do not know how to check for code overwrites in java or any other language. Is there a debugger for java? can you point out where to look for help in identifying code overwrite errors.
|
|
|
|
|
The print statements suggest that the value is correct at the point you call drawString . So the only conclusion must be that some other code is overwriting it elsewhere. However, with such a small code sample in your question it is impossible to guess anything more. If you are using Netbeans or Eclipse as your IDE then I think they both support interactive debugging (Eclipse definitely does). If not then you can use jdb - The Java Debugger[^].
|
|
|
|
|
The fact is I do not know how to use jdb or debugger to spot code overwrite errors. I tried looking on the web, I could not find any. Do you or someone know how to use gbd to spot code overwrite errors? or guide me to a document or example where it is done?
|
|
|
|
|
Sorry, but it is impossible to teach you debugging in a technical form. It is a technique that you really need to learn for yourself, either from online tutorials, or by attending a training course. Time spent learning now will assist you in your future efforts. I already gave you a link to the online documentation, so you can start with that.
|
|
|
|
|
I am working in PSO for feature selection. I use KNN algorithm with 10 cross validation for the evaluation. before I use the 10cv the algorithm is quite cheap meaning no high computational cost has been faced, but after turning to 10cv the code is running too slow, sometimes for days. may I know if there is any problem in performing the 10cv. I use the following code to perform 10 cv:
dataset data = FileHandler.loadDataset(new File(dataSetFileName+".csv"), noFeatures, ",");
int[][] crossvalidationmat= {
{1,2,3,4,5,6,7,8,9},
{0,2,3,4,5,6,7,8,9},
{0,1,3,4,5,6,7,8,9},
{0,1,2,4,5,6,7,8,9},
{0,1,2,3,5,6,7,8,9},
{0,1,2,3,4,6,7,8,9},
{0,1,2,3,4,5,7,8,9},
{0,1,2,3,4,5,6,8,9},
{0,1,2,3,4,5,6,7,9},
{0,1,2,3,4,5,6,7,8},
};
Dataset[] folds = data.folds((10), new Random(1));
Dataset training = new DefaultDataset();
Dataset testing = new DefaultDataset();
int[] tr =new int[9];
int[] te = new int[1];
for (int di = 0; di < crossvalidationmat.length; di++) {
System.out.println(crossvalidationmat[di].length);
for (int xj = 0; xj < crossvalidationmat[di].length; xj++) {
tr[xj]=crossvalidationmat[di][xj];
System.out.print(tr[xj]);
}
te[0]=di;
System.out.println("\nTraing te[0]=di here: "+te[0]);
for (int i = 0; i < tr.length; i++) {
training.addAll(folds[tr[i]]);
}
for (int i = 0; i < te.length; i++) {
testing.addAll(folds[te[i]]);
}
Dataset[] foldsTrain = training.folds(numFolds, new Random(1));
}
|
|
|
|
|
I just found out that you can't have global variables in C#. I think they are supported in other languages like C, C++, Python and maybe Visual Basic.Net.
The program I want to convert to C# has a lot of variables that need to be used in other parts of the program such as procedures. I know you can add variables within the curly brackets for a procedure but in many cases the procedure needs to know about a lot of the variables to function and give a result and the same procedures are used many times in the code. I could use classes but I don't think you can have use the same variable in more than one class.
I'll need to experiment a bit to see if there is anyway around this.
Brian
|
|
|
|
|
You are right, you cannot have global variables, and for good reasons. If a procedure needs access to variables then they should either be declared at the class level (and accessed through the get/set mechanism), or passed in from the calling process(es). Don't try to work round this by hacks, you will just end up down a blind alley, or worse, a buggy application.
Also, please use the correct forum for your questions; this one is for Java not C#.
|
|
|
|
|
Hi Richard.
I'm going to try the get/set and other methods to find a way around this.
I thought I had sent this on the C# forum....my mistake.
Brian
|
|
|
|
|
The use of get/set is to hide the actual variables from the outside users, it has nothing to do with global variables. What you really should be doing is finding how to move all the variables inside the classes that require them.
|
|
|
|
|