max db
hi am fresh in databases...
can any one plz post a complete code of connecting toremote
max dbfrom java desktop application...
and if it needs any special configurations plz tell me about it?!!
thx in advance
contact me atcutout33@gmail.com
hi am fresh in databases...
can any one plz post a complete code of connecting toremote
max dbfrom java desktop application...
and if it needs any special configurations plz tell me about it?!!
thx in advance
contact me atcutout33@gmail.com
Well it is same like how you connect to all other databases using JDBC from a Java Desktop Application(which could be a swing or a AWT based legacy application).
make sure sapdbc.jar is located inside the CLASSPATH and a below code snippet should work as per discussed case.
Connection con = null;
boolean flag = false;
try{
Class.forName("com.sap.dbtech.jdbc.DriverSapDB").newInstance();
flag = true;
}catch(Exception exp){
try{
Class.forName("com.sap.dbtech.jdbc.DriverSapDB");
flag = false;
}catch(ClassNotFoundException cnfe){
cnfe.printStackTrace();
}
}
if(flag){
try{
con = DriverManager.getConnection("jdbc:sapdb://<hostname>:<applicationport>/database_name",username,password);
}catch(SQLException sqe){
}
}
However, you may have a look at the below links for more insight information
http://dev.mysql.com/doc/maxdb/en/ef/2de883d47a3840ac4ebb0b65a599e5/content.htm
http://www.atlassian.com/software/jira/docs/v3.8/databases/maxdb.html
Hope this might help :)
REGARDS,
RaHuL
thanks RaHuL for being kind.
i manged to connect to the db from the same computer
but the problem is how to invoke the IP in the url
am doing something like this
jdbc:sapdb://192.168.110.195:7210/test
but it keeps telling me that connection timed out
what is the problem here ?!!!
yes am able to ping the remote host and i can share files etc..
there are no firewall at all
but am not sure how to check #2 ?!!
the code and the error am getting is as follows
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class MaxDB {
public static Connection conn;
static String username;
static String password;
static String urlConn;
public static void main(String[] args) {
MaxDB m = new MaxDB();
try {
m.connect("fadi", "cutout", "jdbc:sapdb://192.168.110.195:7210/test");
} catch (SQLException e) {
}
}
public void connect(String user, String pass,
String url) throws SQLException {
this.username = user;
this.password = pass;
this.urlConn = url;
try {
Class.forName("com.sap.dbtech.jdbc.DriverSapDB");
conn =
DriverManager.getConnection(urlConn, username, password);
conn.setAutoCommit(true);
System.out.println("connected to DB...");
} catch (Exception e) {
e.printStackTrace();
} // catch
} // connect
}
========================================================
com.sap.dbtech.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC:
Cannot connect to jdbc:sapdb://192.168.110.195:7210/test
[Cannot connect to host 192.168.110.195 [Connection timed out: connect], 813-.].
at com.sap.dbtech.jdbc.DriverSapDB.connect(DriverSapDB.java:188)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at db.MaxDB.connect(MaxDB.java:35)
at db.MaxDB.main(MaxDB.java:21)
thanks
yeah go back to
telnet <HOSTNAME> <APPLN_PORT_ID>
could be a simple test
however,try to run a port scanner at the host where database is running.
You need to make sure the service is running in that machine and make sure that there is no firewall / antivirus or a Malware which trying to block incoming / outgoing packets on the specific application port...
the problem was in the windows firewall...
I've done a port scan using a program called
free port scan and i found that port 7210 is closed
so i went to
control panel> windows firewall> exceptions > add port
and i added this port then i tried to connect and it worked :)
thanks Rahul , developer_jps...
and keep helpin' the needy :)