A few days ago, I made a student management system's curriculum design, and now I do something summary.
First, since it is familiar with Java, I decided to use Java as a development language. The database uses SQL Server2000 and the development tool uses open source Eclipse3.0. Since this is my first time I use Eclipse, I spent a lot of time in a familiar tool.
It is possible to implement maintenance and query of three tables, courses, classes, classes, and browse any records in the database. You can add, modify, delete, and browse any records. Data in any table is queried by different conditional queries, and you can combine multiple conditions. For basic safety reasons, database operations can only be performed by a particular license person, so I also contain authentication.
Development process: January 7th to January 9th: These days are basically in the exploration tool. The function of Eclipse is more powerful, plus a visual plugin, which can easily generate interface code. The framework of the entire program draws on Metalworks in Demo, which comes from JDK. This Demo demonstrates the implementation of multi-document programs, which has a big reference value for me. Finally, my program is affected from the code to the interface, for code It is very helpful in standardization. This time I learned the previous lesson, and the structure of the entire program before the development, divide each function into different modules, and finally integrated, and then a class containing the main method. In this way, although it has taken a lot of time, but it is great for the future, it is very convenient for functional addition and implementation. This experience makes me deeply understand the importance of software engineering, and has accumulated a certain experience in the future. Since Eclipse's plugins are looking for and installed, there is a lot of freedom. The interface design I use Jigloo plug-ins, just the drag control can be done, but in the design, I made an error, manually modify the automatically generated code, resulting in multiple errors after the modification interface, manually modified The change interface is wrong again, and finally all the restles have been done, delaying a lot of time. January 10: After completing the basic framework and student maintenance interface, it involves the operation of the database from this day. There are two ways to connect the SQL Server database in Java, one is the JDBC driver for installing Microsoft, one is through the JDBC: ODBC Bridge. Considering that this is just a desktop application, it uses a second way, and there is no need to install it. First, add data sources to system data source management, then use class.forname ("Sun.jdbc.odbc.jdbCodbcDriver); connect the database. The database connection is done in the Bridge class, and the database operation is implemented by the Manage class. First test the connection, since the user information is included in the UserS table, directly execute "SELECT UPASSWORD AERS WHERE Uname = / '" log.getuser () "/'", get the content of the Upassword field, put It compares to the content of the text segment, and login successs activates the maintenance and query menu. January 11: The front day before yesterday has been done well, and this day is achieved. The process of implementing is not complicated but is more cumbersome, because the fields are much. Where the resultSet cursor cannot go back and move, after viewing the JDK document, found the ResultSet default property is type_forward_only, so set the parameters to resultset.Type_Scroll_Sensitive, resultet.concur_read_only, which can be accessed in the table The location of the data. January 12: The afternoon will play a half-day ball, and take the query function of the student watch at night. I generate a query statement through several checkbox. The corresponding string is selected for the query, otherwise it is empty, and finally combines all the strings, generate query statements, and put the results in a Textarea.
This process encounters a small problem. Because of the "AND" connection during several conditional queries, since the number of conditions is uncertain, it can only be added "AND" after each string generated, so combined In the last, there will be a "and", I use the substring () method to remove the last "and", so it is successful. Another point, because my result output is combined into a string method, this shows that the word length will not be aligned, although I used "/ t" to move indent, but if I encountered very long String, it will be more reward than other rows, and there seems to be no good solution. Perhaps the result is output to a form, but the size of the table is fixed, so it must be generated after the query is completed, this method should be possible, but in order to hurry, I can't achieve it, other queries The interface is also a method of using this defective text output. After this is done, there is no obstacle, I have completed the maintenance and inquiries of the curriculum in a breath. January 13: The last two interfaces, the query and maintenance of the class table. These basic and front, because I have separated the functionality and interface, the event registration is separated, so when you design the interface, then copy the code, and then change the control name, field name. It's okay, so progress is very smooth, an hour an interface, soon it is ready. Finally, I made a description dialog and I was very good! Below is the interface after the login:
There is a problem: One has already said above, is that the long text in the results of the query cannot be aligned, but this will not be encountered, because there is a small chance to fill a long text, but this is a defect. Also, in order to remove the space in the field, I used the Trim () method to ignore the space in the result in the result, but once the NULL returned, there will be an exception of the empty pointer, and this contradiction is mainly generated for the purpose of output. If you should have this problem if you use JTABLE. There is also a warning dialog box when deleting records, I didn't succeed according to the documentation, but I didn't know where it was. In addition, I don't want to set the data source to connect, that is, the so-called passive connection, it is possible to use Access, this is not. Finally, when you get the results of the query, I use getString (String ColumnName) method to assign each column one by one to the result string, but there is a method: getString (int columnIndex) is using the column number to return As a result, all assignments can be completed in this way. However, I use this method to get "illegal descriptor index" abnormal, Best can't understand, the Internet and others discussed did not yet. This problem hopes that all roads can enlighten me!