0

Is there any way to host my MySql server online or on my PC so that i(other people) can access it over the internet?.If so what

package Bookwl; import java.util.*; import java.sql.*; public class Bookwl{ Connection con = null; ResultSet rs = null; Statement stmt = null; public static void main(String[] args){ /*Enter 1 to find out and 2 to insert one */ int a=2; Scanner scn=new Scanner(System.in); System.out.println("Enter 1 to find out and 2 to insert:"); int option = scn.nextInt(); if(option==1){ try{ Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/hey?autoReconnect=true&useSSL=false","root","army"); Statement stmt = con.createStatement(); String query="SELECT * FROM yolo"; ResultSet rs=stmt.executeQuery(query); while(rs.next()){ String nm=rs.getString("book"); String ph=rs.getString("votes"); System.out.println("The book is"+nm+"with total votes of"+ph); } rs.close(); stmt.close(); con.close(); } catch(Exception e){ System.out.println("You messed up"); } } else if(option==2){ a =2; } else{ } } }

8th Jul 2017, 5:01 PM
Deba Kun
Deba Kun - avatar
1 Answer
+ 2
If you have the sql server running on your home network in order to access it outside of you network you will need to set up a port forward on your router so that any traffic going to your external ip gets routed to the ip address of the machine running the sql server. Also you will have to create a user in the database and specify the ip address like User@"whatever your external ip is at the time". You can use at wild card to let in all ip address but make sure you password protect it.
28th Jul 2017, 4:10 PM
Arthur Tripp
Arthur Tripp - avatar