It looks like i can connect via the obdc now but im having a hard time figuring out how to connect
to a specific schema/database. This cause I have several databases;
i.e.
information_schema (17)
mysql (17)
sugarcrm (99)
test (0)
my usual way of connecting via java is so
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package connectsugar;
import java.sql.ResultSet;
import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
/**
*
* @author Chase
*/
public class Main {
private static Connection conn;
private String SQLStatement;
private String url;
private static Statement stmt;
private ResultSet rset;
int cid=0;
public void test(){
try {
ResultSet rs;
String url = "jdbc:odbc:db";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(url, "root@localhost", "1234");
stmt = (Statement) conn.createStatement();
SQLStatement = "SELECT MAX(Branchno) as 'max' FROM branch";
rs = stmt.executeQuery(SQLStatement);
rs.next();
cid = rs.getInt("max");
cid++;
stmt.close();
conn.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
public static void main(String[] args) {
}
} I was wondering how to connect to specific db's using this format. If i can't can anyone suggest how to connect using java?
Bookmarks