Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Problem with connecting to DataBase

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Location
    Iran
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Problem with connecting to DataBase

    Hi
    I'm trying to connect to database with jdbc in netbeans.
    I use this code :
        String host = "jdbc:derby://localhost:1527/MIRDataBase [mir on MIR]";
                String name = "mir";
                String pass = "mir" ; 
                con = DriverManager.getConnection( host, name ,pass );

    as you see I set username and password but I get this error :
    Jan 07, 2013 4:02:19 PM DataBase.Crawler_DataBase <init>
    SEVERE: null
    java.sql.SQLNonTransientConnectionException: User id length (0) is outside the range of 1 to 255.
    	at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
    	at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
    	at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
    	at java.sql.DriverManager.getConnection(DriverManager.java:579)
    	at java.sql.DriverManager.getConnection(DriverManager.java:221)
    	at DataBase.Crawler_DataBase.<init>(Crawler_DataBase.java:33)
    	at crawler.WebCrawler.<init>(WebCrawler.java:28)
    	at webScanner.WebResourceScanner.main(WebResourceScanner.java:62)
    Caused by: org.apache.derby.client.am.SqlException: User id length (0) is outside the range of 1 to 255.
    	at org.apache.derby.client.net.NetConnection.checkUserLength(Unknown Source)
    	at org.apache.derby.client.net.NetConnection.checkUser(Unknown Source)
    	at org.apache.derby.client.net.NetConnection.checkUserPassword(Unknown Source)
    	at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source)
    	at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
    	at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
    	at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(Unknown Source)
    	... 6 more

    I've attached my db properties
    Does anybody know what's wrong with my connection ?
    Thank you
    Attached Images Attached Images


  2. #2
    Junior Member
    Join Date
    Dec 2012
    Location
    Iran
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Problem with connecting to DataBase

    My problem solved but I want to explain about solution. it might helped someone
    problem was about apache setting. I add apache to server in service tab in netbeans and edit it's xml setting file (tomcat-users.xml) and add more access to my user with proper username and password :
    roles="manager-gui,manager-script,manager-jmx,admin"
    it's working now
    and one more point. if you want to create an application which has access to database you may add something like this :
    permission java.net.SocketPermission "127.0.0.1:1527", "connect, resolve";
    to .java.policy file

    by the way thank you java forum

  3. The Following User Says Thank You to ocean1991 For This Useful Post:

    copeg (January 11th, 2013)

Similar Threads

  1. Error connecting to database
    By bczm8703 in forum JDBC & Databases
    Replies: 9
    Last Post: December 8th, 2011, 01:06 AM
  2. Problem With Applet Connecting With Microsoft Access Database
    By Saurabh Mittal in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 29th, 2011, 10:43 AM
  3. Looking at Exploring Database Connecting
    By aussiemcgr in forum JDBC & Databases
    Replies: 2
    Last Post: August 12th, 2010, 03:40 PM
  4. Connecting to a database
    By fwashington in forum JDBC & Databases
    Replies: 5
    Last Post: March 15th, 2010, 01:37 PM