这样恐怕不行吧,我还没有试过用jdbc-odbc桥来指向一个url

解决方案 »

  1.   

    应该是不正确的,驱动桥应该是指定本机的DSN,个人想法而已
      

  2.   

    ("jdbc:odbc://192.168.238.35","sa","");数据名呢?
      

  3.   

    /**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2003</p>
     * <p>Company: </p>
     * @author unascribed
     * @version 1.0
     */public class test {
      /**
        * JDBC URL, initialized from com.mysql.jdbc.testsuite.url
        * system property, or defaults to jdbc:mysql:///test
        */  public test() {
      }
      public static void main(String[] args) {
        Connection conn = null;          try
              {
               File file = new File("c://dd.bmp");
               FileInputStream fis = new FileInputStream(file);
               Object sd = (Object)fis;
               int lenth = 0;
               lenth= (int)file.length();
               Class.forName("org.gjt.mm.mysql.Driver").newInstance();
               String url ="jdbc:mysql://192.168.238.35/mail?useUnicode=true&characterEncoding=gb2312";
               String str = "小dd";
               conn= DriverManager.getConnection(url,"root","");
               PreparedStatement ps = conn.prepareStatement("INSERT INTO test VALUES (?)");
               ps.setString(1,new String(str.getBytes("gb2312")));
            //   ps.setObject(2,sd);
               FileInputStream dsd = (FileInputStream)sd;
               //Statement stat=conn.createStatement();
              // ResultSet rs=stat.executeQuery("select * from custom_folder");
              // System.out.println(rs.next()) ;
               ps.executeUpdate();
               ps.close();
              }
              catch (Exception e)
              {
                  e.printStackTrace();
                  System.err.println ("Cannot connect to database server");
              }
              finally
              {
                  if (conn != null)
                  {
                      try
                      {
                          conn.close ();
                          System.out.println ("Database connection terminated");
                      }
                      catch (Exception e) { /* ignore close errors */ }
                  }
              }  }
    }
      

  4.   

    import java.sql.*;
    import java.io.*;public Example{
        static String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";  
        Connection connection;
         
        Class.forName(driver);
        connection = DriverManager.getConnection ("jdbc:microsoft:sqlserver://server1:1433","username","pswd"); 
        
    }1.server1 是数据库机器的名字或ip
    2.这是针对MS SqlServer 的,并且你要安装 “SQL Server 2000 Driver for JDBC“驱动
    3.其它的数据库的话你要修改 driver 和 getConnection() 的参数,具体的网上查吧