Hello im trying to connect database with my java program for register/login but im not doing well, i have online database on godaddy and i cannot connect with the java program i tryed with using the URLEncoder
and it works for registering but for loging in i cannot make it please help me to connect it...
show me the code and i will just change the host, username and password ...
Thank you ! :)
Stefce 146 Posting Pro
Recommended Answers
Jump to PostYou need to add .jar from mysql driver to your project and then just do like this...
public static void main(String[] args) { try { Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("server adress","username","password"); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("querry"); while(rset.next()) { // do what ever you want... …
Jump to Post
Class.forName("com.mysql.jdbc.Driver");
This hasn't been needed for years.
Stefan, read about how Java works. That's an extremely basic question. The driver jar needs to be on your classpath.
All 6 Replies
Stefce 146 Posting Pro
milil 24 Newbie Poster
Stefce 146 Posting Pro
milil 24 Newbie Poster
jwenting 1,905 duckman Team Colleague
Stefce 146 Posting Pro
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.