java - networking javaSE applications -


this db class javase application.

public class db {     static connection c;     public static connection get_connection() throws classnotfoundexception,sqlexception {         if (c == null) {             string ip = "";             string port = "";             string username = "";             string password = "";             try {                 bufferedreader br = new bufferedreader(new filereader(system.getproperty("user.home") + "/connectionsettings.txt"));                    ip = br.readline();                 port = br.readline();                 username = br.readline();                 password = br.readline();                 br.close();             } catch (exception e) {                 e.printstacktrace();             }             class.forname("com.mysql.jdbc.driver");             c = drivermanager.getconnection("jdbc:mysql://" + ip + ":"+port + "/mydb", username, password);         }         return c;     } 

i know isn't practice. i'm getting ip address, database password , port text file saved in c:/...

my question is, if want network project okay provide ip address of server machine in db class?

if not tell me why, , how network javase applications?

it's okay if provide answers in links.

what frameworks should using network applications?

will hibernate solution this?

if you're talking making network connection existing database server, code adequate. in real application, you'd want use more flexible method of storing connection parameters, boils down to.

persistence frameworks jpa (hibernate) , spring data sit on top of connection , convert between sql , java objects. whether use 1 depends on you're trying in application.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -