I have been learning java for about 3 weeks. I wanted to connect mysql with java and I'm trying now. But there is a problem. I have already installed php,apache,mysql three in for my ubuntu. And I can reach phpmyadmin from port 80. I think there is a problem when connecting database this is why I said port.
Here is the my table:
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(2) | NO | PRI | NULL | auto_increment |
| name | varchar(32) | NO | | NULL | |
+-------+-------------+------+-----+---------+----------------+
And here is the java code:
import java.sql.DriverManager;
import java.sql.Statement;
public class Main {
public static void main(String args[]) {
try {
java.sql.Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:80/test", "root", "1");
Statement state = (Statement) conn.createStatement();
String name = "try";
state.executeUpdate("INSERT INTO deneme (name) VALUES (" + name + ")");
} catch (Exception e) {
}
}
}
This code runs about 20 seconds and returns BUILD SUCCESSFUL (total time: 21 seconds) What is your idea about this problem?